What is the best way to place two radio button inside a simple_form, where one button is by default disabled and another is selected!
f.input_field :listing_type, as: :radio_buttons, collection: [ "lease", "sale"], :item_wrapper_class => 'inline'
this is giving me two buttons where both are enabled and selected. I want sale to be disabled and lease to be selected by default.
Here's an updated answer. You can:
collection: [['op1', 'val1', disabled: false], ['op2', 'val2', disabled: true]]checked: value_to_be_checked to the main options hash.
Here's an examples of both options:example1:
<%= f.input_field :listing_type, as: :radio_buttons, collection: [ ['lease', 'lease', disabled: false], ['sale', 'sale', disabled: true]], checked: 'lease', :item_wrapper_class => 'inline' %>
example2:
<%= f.input_field :listing_type, as: :radio_buttons, collection: [ ['lease', 'lease', disabled: false, checked: true], ['sale', 'sale', disabled: true]], :item_wrapper_class => 'inline' %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With