jbsound
jbsound

Reputation: 787

Symfony 2: Using Twig extension in form builder

I need to change the way a value or label is formatted with a custom filter. However, I need to do this from the form builder rather than in the twig template itself. In other words, when I build my form in the abstract type class, I need to be able to apply specific formatting.

Here is one application where this is needed:

Labels assigned to form elements are based on the database table field names. I need to be able to change how those labels are rendered, such as title case, or upper case, etc.

What's the best way of doing this?

Thanks!

Upvotes: 3

Views: 1331

Answers (1)

smoreno
smoreno

Reputation: 3540

You can create a custom form field type, that extend from choice or entity field type. Then you can customize the template for the field applying filters or whatever you want.

Upvotes: 2

Related Questions