Phoenix select と radio_button

2018年5月21日 Posted by PURGE

■ selectタグの場合

  <div class="form-group">
    <%= label f, :gender, class: "control-label" %>
    <%= select f, :gender_cd, ["男性": "1", "女性": "2", "その他": "0"], class: "control-label" %>
    <%= error_tag f, :team %>
  </div>

■ radio button タグの場合

  <div class="form-group">
    <%= label f, :gender, class: "control-label" %>
    <%= radio_button f, :gender_cd, "1", checked: true, class: "control-label" %>男性
    <%= radio_button f, :gender_cd, "2", class: "control-label" %>女性
    <%= radio_button f, :gender_cd, "0", class: "control-label" %>その他
    <%= error_tag f, :team %>
  </div>

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です