Can I put html inside a Symfony form button with Twig?

前端 未结 5 1589
暗喜
暗喜 2021-02-02 09:06

I\'m trying to put html inside a form button with twig like:

{{ form_widget(form.jiraStatus, {
        \'label\': \'Bug\',         


        
5条回答
  •  -上瘾入骨i
    2021-02-02 09:48

    An even simpler solution might be to leave the buttons out of the form type and set name and value attributes. Then retrieve them as you would normal post parameters in the controller.

    In your template:

    {{ form_start(form) }}
    
    
    
    

    Then in your controller

    if ($form->isSubmitted() && $form->isValid()) {
        $clicked = $request->request->get('clicked');
    }
    

提交回复
热议问题