Using Rails, I would like to add: <span class='req'>•</span> within my <label> tags in my views, if I set an option on the label form helper; i.e.
<%= f.label :address_1, "Address 2:", :req => true -%>
should produce:
<label for="model_address_1"><span class='req'>•</span> Address 1:</label>
rather than:
<label for="model_address_1" req="true">Address 1:</label>
as it does now. I realise I may have to override the default form builder or create my own form builder, but don’t know how to do this. Any suggestions? Thanks in advance!
Update: I’m doing this in an attempt to DRY up my code, and I realise that I could just paste the span snippet above into all the labels in all of my views but I’d like to avoid that.
This is untested, but something along these lines should work.
And then use that builder in your view
You might be interested in Episode 3 of my Mastering Rails Forms screencast series where I go into detail on creating form builders.