Damir Nurgaliev
Damir Nurgaliev

Reputation: 361

How to configure simple_form label correctly

I have a ready html layout. It look like this(!SLIM USING!):

label.modal__form-label Имя
input.modal__form-control type="text" required="" minlength="3"

Its generate this code:

<label class="modal__form-label">Имя</label>
<input class="modal__form-control" minlength="3" required="" type="text">

That's what I need.

I pasted my rubycode instead this. Ruby code:

= f.input :name, input_html: { minlength: "3", type: "text" }, required: true

And get this one html:

<label class="string required" for="feedback_name"><abbr title="required">*</abbr> Name</label>
<input class="string required modal__form-control" minlength="3" type="text" required="required" aria-required="true" name="feedback[name]" id="feedback_name">

So as U see, I need to give a class to label and rename :name into "Имя" in simple form. How can I do this?

Upvotes: 0

Views: 172

Answers (1)

gwcodes
gwcodes

Reputation: 5690

label and label_html should be the additional options that you're looking for. So putting it all together:

= f.input :name,
          input_html: { minlength: "3", type: "text" },
          label_html: { class: "modal__form-label" },
          label: "Имя",
          required: true

Upvotes: 1

Related Questions