EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Impossible to access an attribute ("customOptions")

Open GCalmels opened this issue 6 years ago • 5 comments

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)
        ;

GCalmels avatar Sep 03 '20 05:09 GCalmels

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

finnef avatar Sep 07 '20 08:09 finnef

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

vic-blt avatar Sep 07 '20 15:09 vic-blt

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.

GCalmels avatar Sep 08 '20 07:09 GCalmels

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

vdubyna avatar Nov 09 '20 21:11 vdubyna

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!

javiereguiluz avatar Oct 04 '21 18:10 javiereguiluz