A
A
AlpineMilk2019-01-19 18:43:37
symfony
AlpineMilk, 2019-01-19 18:43:37

How to nest a tag in a symfony form field?

there is a submit field made in the form class

->add('save', SubmitType::class,[
        'attr' => [
          'class' => 'btn-success btn-anim'
        ]
      ]);

in the template is displayed in the usual way {{ form_row(form.save) }}.
How can I nest an `i, span` tag with the required classes in a button? Like here:
<button type="submit" class="btn btn-success btn-anim"><i class="icon-rocket"></i><span class="btn-text">submit</span></button>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis, 2019-01-19
@prototype_denis

Override form theme for widget _{form_name}_save_widget
https://symfony.com/doc/current/form/form_customiz...

D
Denis, 2019-01-19
@sidni

I often read that many do according to the scheme as suggested by BoShurik

{{ form_start(form) }}
    {#{ form_widget(form) }#}
    {{ form_errors(form) }}
    {{ form_row(form.name) }}
    {{ form_row(form.slug) }}
    <button type="submit" class="btn btn-success btn-anim"><i class="icon-rocket"></i><span class="btn-text">submit</span></button>
{{ form_end(form) }}

And in the form builder, the record about the button is removed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question