2017-05-19 13 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"> 

代わりに私のルビーコードを貼り付けました。 Rubyコード:

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

そして、この1つのHTMLを取得:Uが見る

<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

labelおよびlabel_htmlは、あなたが探している追加オプションです。だから一緒にまとめる:

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