EasyCorp / EasyAdminBundle

EasyAdmin is a fast, beautiful and modern admin generator for Symfony applications.
MIT License
4.04k stars 1.02k forks source link

Impossible to access an attribute ("customOptions") #3729

Closed GCalmels closed 2 years ago

GCalmels commented 4 years ago

I created a form : collection => collection => TextEditorType and in src/Resources/views/crud/form_theme.html.twig for ea_text_editor_widget and for ea_code_editor_widget, we need form.vars.ea_crud_form.ea_field not null... I would like to know is there is a way to add data to ea_field via FormType ?

My code

$sections = CollectionField::new('sections')
            ->setFormTypeOptions([
                'entry_type' => ProjectSectionType::class,
                'allow_add' => false,
                'allow_delete' => true,
                'by_reference' => false,
            ])
        ;

And in ProjectSectionType, there is an other collection of FormType

$builder
            ->add('translations', CollectionType::class, [
                'entry_type' => ProjectSectionTranslationType::class,
                'by_reference' => false,
                'allow_add' => true,
                'allow_delete' => true,
            ])
;

And in ProjectSectionTranslationType, there is a TextEditorType :

$builder
            ->add('content', TextEditorType::class)
        ;
finnef commented 4 years ago

Yes, would by nice to know generally if its possible to use EA field types in normal symfony forms?

vic-blt commented 4 years ago

I had the same issue. I just updated EasyAdmin to the latest version 3.1.4 It was fixed in this PR https://github.com/EasyCorp/EasyAdminBundle/pull/3610

GCalmels commented 4 years ago

Hey @vic-blt, it's not really the same issue. The PR only checks if ea_field is not null but in my example, I need ea_field to be not null but I don't know how... For example, code_editor_widget will check language in ea_field so we cannot only check if ea_field is not null, we need to add these attributes in our FormType.

vdubyna commented 3 years ago

Have the same issue, I've compared to v2 and same code worked there.

javiereguiluz commented 2 years ago

Closing because this might have been fixed in one of the latest releases. If not, please try to find the exact place in the form theme where this fails and try to make a pull request adding some Twig |default filter when needed. Thanks!