Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: How to disable asterisk on form's required fields?

When I add the 'Required' attribute
to html input fields, Rails pre-pends an asterisk (*) before the label.

Does anyone know how to prevent this?

For some reason Rails transforms this:

<%= f.input :Company, :input_html => {:value => "", :id => "company_name"}, :label => "company name" %> 

into this:

<div class="input string required">     <label for="company_name" class="string required">     <abbr title="required">*</abbr> company name</label>     <input type="text" value="" size="50" required="required" name="lead[Company]" id="company_name" class="string required"> </div> 

I don't like that it wraps everything in a DIV and adds an ABBR element to the party.

How can I prevent this?

like image 638
vsync Avatar asked Oct 04 '11 15:10

vsync


People also ask

How do I hide an asterisk?

Removing the Required AsteriskGo to Style > Text > Text Options and uncheck the option Show Required Asterisks.

What is Fields marked with an asterisk (*) are required?

Fields marked with * are mandatory Using an asterisk (*) symbol content authors notify mandatory field. This is said to be one of the accessible modes of identifying a mandatory field, however this method also will be a problem with screen readers in certain times.


1 Answers

You can just set the required mark to empty value in simple_form's locale file:

en:   simple_form:     required:       text: 'required'       mark: '*' 

Or use CSS to hide it.

like image 195
RocketR Avatar answered Sep 29 '22 07:09

RocketR