Skip to content

first post invalid message #232

@kadlama

Description

@kadlama

I get an error message on my first post. Then when I send it again it succeeds.
I couldn't solve the problem. There is a generated dynamically form field in the form.
Could this have an effect? What could be the cause of the problem?

->add('basvurucaptcha', CaptchaType::class,array());

    $formModifier = function (FormInterface $form, Il $il = null) {
        $ilces = null === $il ? [] : $il->getIlces();
        $form->add('ilce', EntityType::class, [
            'class' => Ilce::class,
            'placeholder' => 'Seçiniz',
            'choices' => $ilces,
            'disabled'=>count($ilces)==0?true:false,
        ]);
    };

    $builder->addEventListener(
        FormEvents::PRE_SET_DATA,
        function (FormEvent $event) use ($formModifier) {
            // this would be your entity, i.e. SportMeetup
            $data = $event->getData();
            $formModifier($event->getForm(), $data->getIl());
        }
    );

    $builder->get('il')->addEventListener(
        FormEvents::POST_SUBMIT,
        function (FormEvent $event) use ($formModifier) {
            $il = $event->getForm()->getData();
            $formModifier($event->getForm()->getParent(), $il);
        }
    );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions