form-extensions
form-extensions copied to clipboard
Add nested fields form type, which stores multiple nested fields, groups of fields and collections of fields in one json field
Feature Request
Example of usage :
protected function configureFormFields(FormMapper $formMapper): void
{
$formMapper->add('contactInfo', NestedFieldsType::class, [
'subfields' => [
[
'items', CollectionType::class, [
'subfields' => [
['title', TextType::class],
['image', ModelListType::class, ['link_parameters' => ['context' => 'post_thumbnail']]],
]
]
],
['group', GroupType::class, [
'subfields' => [
['title', TextType::class],
['image', ModelListType::class, ['link_parameters' => ['context' => 'post_thumbnail']],
]
]
],
],
['title', TextType::class],
['content', CKEditorType::class],
]]);
}
Example of resulting json:
{
"items": [
{
"title": "Test",
"image": "image.png"
},
{
"title": "Test 2",
"image": "image.png"
},
{
"title": "Test 3",
"image": "image.png"
}
],
"group": {
"title": "Test",
"image": "image.png"
},
"title": "Test",
"content": "<p>Test <strong>Bold</strong></p>"
}
FormMapper field type are just working like a basic Symfony FormType. So you can implement you own FormType.
then it will be easy to provide a PR to https://github.com/sonata-project/form-extensions
Maybe It´s simmilar to the ImmutableArrayType
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.