Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first post invalid message #232

Open
kadlama opened this issue Oct 24, 2022 · 0 comments
Open

first post invalid message #232

kadlama opened this issue Oct 24, 2022 · 0 comments

Comments

@kadlama
Copy link

kadlama commented Oct 24, 2022

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);
        }
    );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant