a2lix / AutoFormBundle

Automate Symfony form building
https://a2lix.fr/bundles/auto-form
MIT License
83 stars 30 forks source link

This commit ensures that the "property_path" option is respected #43

Closed bresam closed 10 months ago

bresam commented 10 months ago

This commit ensures that the "property_path" option is respected in the DoctrineORM manipulator. If no property_path is specified, the form name is used as before.

When using TranslationFormBundle, we noticed that the "property_path" option is only partially/incompletely taken into account. Here we sometimes use several translation sections in one Sonata Admin. This already worked in the older TranslationFormBundle version.

The Structure is like:

Below is a small code example of the form:

$form->add('translations', TranslationsType::class,
    [
        'property_path' => 'translations', // not required cause already defined by form name
        'locales' => $this->getLocales(),
        'label' => false,
        'fields' => [
            'text1' => ['field_type' => TextareaType::class, ...],
            'text2' => ['field_type' => TextareaType::class, ...],
         ],
         'excluded_fields' => ['text3', 'text4']),
    ]
)
->add('translations_not_existing_property_name', TranslationsType::class,
    [
        'property_path' => 'translations', // required (used form name doesn't exist anyway)
        'locales' => $this->getLocales(),
        'label' => false,
        'fields' => [
            'text3' => ['field_type' => TextareaType::class, ...],
            'text4' => ['field_type' => TextareaType::class, ...],
         ],
         'excluded_fields' => ['text1', 'text2']),
    ]
)
->end();
bresam commented 10 months ago

@webda2l it seems the failing check has nothing todo with my change. Right? Do you have any further comments on this feature?

webda2l commented 10 months ago

Sound good, thanks!