BigDataLearner
BigDataLearner

Reputation: 1468

Unable to click radio button in Ruby ActiveAdmin

I am displaying a form using ruby on rails as follows.

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

This displays the form correctly, but the problem exists when I click the radio button. I am unable to select the radio button. By default Yes is selected, but when I click on No, it doesn't allow me.

Any help will be appreciated.

Rails version : 4.2.0

Upvotes: 1

Views: 454

Answers (1)

Mayur Shah
Mayur Shah

Reputation: 3459

There is way, Try to replace your with

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

As given below:

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

Upvotes: 1

Related Questions