EasyCorp / EasyAdminBundle

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

Complex form - Impossible to access an attribute ("customOptions") on a null variable. #3719

Closed oskar-gp closed 2 years ago

oskar-gp commented 4 years ago

While creating complex form with 2-level depth there is an error from vendor/easycorp/easyadmin-bundle/src/Resources/views/crud/form_theme.html.twig (line 117) bug report

My code:

Field

CollectionField::new('offerPackages')
                    ->setLabel($this->translate('offer-elements'))
                    ->setEntryType(\App\Form\OfferPackageType::class)
                    ->setFormTypeOptions([
                        'allow_add' => true,
                        'delete_empty' => false,
                        'allow_delete' => true,
                    ]),

Form 1

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

Form 2 (end form)

public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('component', EntityType::class, [
                'class' => OfferComponent::class,

            ])
            ->add('quantity', NumberType::class)
            ->add('minPrice', MoneyType::class, [
                'currency' => 'USD',
            ])
        ;
    }
GCalmels commented 4 years ago

I think this issue is fixed by the last version (3.1.4)

oskar-gp commented 4 years ago

It is in a little part. In v3.14 it doesn't throw an error, but there is no frontend interaction inside the form: extended-form-test(1)

javiereguiluz commented 2 years ago

Closing this old issue because we made many changes to this type of field, so hopefully this was solved or it's no longer relevant. Thanks.