Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding * to required form labels

Does anybody have a nice way of adding * to required form labels, without having to turn to tools like SimpleForm?

I did not like the way SimpleForm added all these weird wrappers and classes to my stuff. I thought the point of SimpleForm was to allow you to write simple, semantic form ERB (which it most certainly does) - but not at the same time mess up your existing layout by adding wrappers and classes at random. I always style my forms before I bring them to Rails, so I like to tell it what classes to use, not the other way around.

like image 726
Mark Boulder Avatar asked Mar 08 '12 17:03

Mark Boulder


1 Answers

Can't you just simply style your labels?

Your label:

<label class="required">MyRequiredField</label>

Your css.

label.required:after{content:"*"}

Or am I missing what you're trying to accomplish?

like image 74
miked Avatar answered Sep 29 '22 14:09

miked