I'm new to Symfony, currently working with 4.4, and am trying to implement a simple form theme for one specific form, i.e. the theme is in the same file as the form's html.twig
file. I have my own form_row
block and I'm trying to pass in custom data (an icon to use within the div) when calling it, so something like (this is highly summarised!):
{{ form_row(signUpForm.email, { attr: { placeholder: 'e.g. bobsmith@gmail.com' }, icon: 'envelope'}) }}
then try to render in the form as
{%- block form_row -%}<div> {{ form_label(form) }} {{ form_widget(form, {attr: class: 'input'}) }}<i class="icon {{ icon }}"></i></div>
I tried also passing icon via the formBuilder, along the lines of
$builder ->add('email', EmailType::class, ['attr'=> ['icon' => 'envelope']])
but no joy. Surely this must be possible! Any assistance would be much appreciated. Thanks