Search code examples
ruby-on-railscheckboxruby-on-rails-5isenabled

How do I create a checkbox that's disbaled by default in Rails?


I'm using Rails 5. How do I create a checkbox that is disabled (not clickable) by default? I tried

<%= f.check_box :mybox, :tabIndex => '1', :enabled => false %>

but the resulting checkbox is still rendered as enabled.


Solution

  • You can use the disabled attribute:

    <%= f.check_box :mybox, tabIndex: '1', disabled: true %>