Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2: custom HTML inside label

Is there a way with Symfony 2 forms to add HTML inside a label?

I want:

<label for="myfield"><span class="photo">My label</span></label>

How can I write it? None of these ideas work properly as expected:

<span class="photo">{{ form_label(form.myfield) }}</span>

Or

{{ form_label(form.myfield, '<span class="photo">'~myfield~'</span>') }}

Thanks for your help, A

like image 485
Aurel Avatar asked Apr 02 '12 10:04

Aurel


1 Answers

Take a look to Symfony2 Form theming documentation, especially to the "Adding a "Required" Asterisk to Field Labels" section.

I am not sure this is the best way to go, but it should work.

like image 128
Andrea Avatar answered Sep 22 '22 06:09

Andrea