Symfony2 Form Anchors

独自空忆成欢 提交于 2019-12-11 19:47:02

问题


I have a number of forms on the one page under different tabs

After the form is processed, I would like to return to the same tab as the form was sent from.

Basically, I would like to modify the target_route to go to the current page with an Anchor at the end of the URL. (EG company/view/6#editdetails)

Could someone provide or link to an example that I can put in my controller or into twig?


回答1:


The answer is simply:

    $form = $this->createForm(new ContactType($contact), $contact, array(
            'method' => 'POST',
            'action' => '#editdetails'
        ));



回答2:


You may also set this in the template itself as an attribute. See example:

{{ form_start(form, {attr: { novalidate: "novalidate", class: 'requiredStar', action: '#form' }}) }}


来源:https://stackoverflow.com/questions/23400409/symfony2-form-anchors

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!