【问题标题】:Unable to click radio button in Ruby ActiveAdmin无法单击 Ruby ActiveAdmin 中的单选按钮
【发布时间】:2017-07-31 12:35:22
【问题描述】:

我正在使用 ruby​​ on rails 显示一个表单,如下所示。

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

【问题讨论】:

  • 您找到解决上述问题的方法了吗?

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


【解决方案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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-13
    • 2019-08-18
    • 1970-01-01
    • 2019-11-28
    相关资源
    最近更新 更多