2017-05-19 167 views
0

我有一個準備好的html佈局。它看起來像這樣(SLIM使用!):如何正確配置simple_form標籤

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

其產生這樣的代碼:

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

這就是我所需要的。

我粘貼我的rubycode而不是這個。 Ruby代碼:

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

而獲得這一個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"> 

所以當你看到,我需要給一個類來標記和重命名:以簡單的形式命名爲「Имя」。我怎樣才能做到這一點?

回答

1

labellabel_html應該是您正在尋找的其他選項。所以把它放在一起:

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