AngularJS blocks submit button in symfony2 form

后端 未结 2 1459
死守一世寂寞
死守一世寂寞 2021-01-28 13:33

I have form created in symfony2, which at the end renders button to submit form. When I add ng-app=\"myApp\" everything works fine, but I can\'t submit form which i

相关标签:
2条回答
  • 2021-01-28 13:49

    Well documentation says:

    For this reason, Angular prevents the default action (form submission to the server) unless the element has an action attribute specified

    so you can add action attribute to your form. In my example i am using grenerateUrl function, but you should generate url of your current route(route of controller where the form is generated)

    $data = array();
                $form = $this->createFormBuilder($data,
                    array("action" => $this->generateUrl("route_to_curent_path"))))
                    ->add('field', 'text')
                    ->add('submitButton', 'submit')
                    ->getForm();
    

    EDIT: just now found out that this is a duplicate question here and here and here and here(this link being the most upvoted answer)

    0 讨论(0)
  • 2021-01-28 13:57

    We need more informations, did you let browser validate form ? To remove :

    {{ form(form, { 
        'attr': {
            novalidate,
        },
        }) 
    }}
    

    Maybe errors popup are hidden (happen with various complexe form fields)

    When you said "i can't submit", is the submit button unable ? Errors happen after sumbission ?

    0 讨论(0)
提交回复
热议问题