无法单击Ruby ActiveAdmin中的单选按钮

时间:2017-07-31 01:50:55

标签: ruby-on-rails ruby radio-button

我正在轨道上使用ruby显示表格,如下所示。

form do |f|
    f.semantic_errors *f.object.errors.keys

    # Form creation
    f.inputs "User" do
      f.input :first_name
      f.input :last_name
      f.input :email
      f.input :phone_number, required: false, as: :number
      f.input :password
      f.input :text_sms, as: :radio, :label => "Receive sms", :checked => "Yes"
    end
    f.action
end

这会正确显示表单,但单击单选按钮时会出现问题。我无法选择单选按钮。 默认选择是,但是当我单击否时,它不允许我。

任何帮助将不胜感激。

Rails版本:4.2.0

1 个答案:

答案 0 :(得分:1)

有办法,尝试用

替换你
f.input :text_sms, as: :radio, :label => "Receive sms",:collection => [ ['Yes','yes',{:checked => true}], ['No','no'] ]

如下所示:

form do |f|
    f.semantic_errors *f.object.errors.keys

    # Form creation
    f.inputs "User" do
      f.input :first_name
      f.input :last_name
      f.input :email
      f.input :phone_number, required: false, as: :number
      f.input :password
      f.input :text_sms, as: :radio, :label => "Receive sms",:collection => [ ['Yes','yes',{:checked => true}], ['No','no'] ]
    end
    f.action
end