public function fieldsAction(Request $request)
    {
        $id = $request->get('id');

        $metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');
        $metaSet = $metaSetManager->find($id);
        $fields = $metaSet->getFields();

        $data = [];
        foreach ($fields as $field) {
            $data[] = [
                'id' => $field->getId(),
                'key' => $field->getName(),
                'type' => $field->getType(),
                'required' => $field->isRequired(),
                'synchronized' => $field->isSynchronized(),
                'readonly' => $field->isReadonly(),
                'options' => $field->getOptions(),
            ];
        }

        return new JsonResponse(['values' => $data]);
    }