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.

+3


source to share


2 answers


Could you just create your shortcuts?

Your shortcut:

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

      



Your css.

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

      

Or am I missing what you are trying to accomplish?

+23


source


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



https://github.com/plataformatec/simple_form/blob/master/lib/simple_form/helpers/required.rb

0


source







All Articles