Adding * to labels of the required shape

Does anyone have a good way to add * to the required form labels without having to go to tools like SimpleForm?

I didn't like how SimpleForm added all these weird wrappers and classes to my stuff. I thought the point of SimpleForm is to let you write a simple semantic ERB form (which it certainly does), but not at the same time mess up your existing layout by adding wrappers and classes at random. I've always put my forms in before I put them in Rails, so I like to tell you which classes to use, not the other way around.


source to share

2 answers

Could you just create your shortcuts?

Your shortcut:

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


Your css.



Or am I missing what you are trying to accomplish?



If you don't like their solution, you can see how they are implemented and roll your own:



All Articles