Rails simple form checkbox default to true

Reddirt

How do I make a simple for boolean checkbox default to true?

assign_client is a boolean field.

I tried these:

<%= f.input :assign_client, :label => 'Charge Client?', :true %>
<%= f.input :assign_client, :label => 'Charge Client?', :value => :true %>
<%= f.input :assign_client, :label => 'Charge Client?', :value => 1 %>

Thanks for the help!

zishe

I think you should add input_html:

<%= f.input :assign_client, :label => 'Charge Client?', :input_html => { :checked => true }

proof

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Rails simple form checkbox default to true

From Dev

Ruby Simple Form Checkbox not checking when True

From Dev

setting default timestamp in simple_form_for rails

From Dev

Rails 5.2.0 - scaffold `form_with` includes `local: true` by default

From Dev

Rails simple_form default input value not showing

From Dev

rails simple_form prevent select adding a blank by default to collection

From Dev

checkbox returning true or false in rails

From Dev

Terms and agreement checkbox in simple form for

From Dev

Angular form checkbox default value

From Dev

Check checkbox by default Rails 4

From Dev

Rails Devise & Simple Form

From Dev

Rails with Simple Form - Styling

From Dev

Simple_form (rails) - How can I set default selected option if I have params[:id]

From Dev

Changing checkbox icon with simple_form

From Dev

Bootstrap 3.2.0 with Simple_form checkbox

From Dev

Redux Form - Checkbox with a default value and set it to be disabled

From Dev

Rails Simple Form Bootstrap Javascript

From Dev

Simple Form - Rails 4 - editing

From Dev

Rails Simple Form Country Select

From Dev

Foundation 6 with Rails Simple Form

From Dev

Bootstrap markdown with Rails and Simple Form

From Dev

Simple Form Select with Rails Bootstrap

From Dev

Rails Simple Form Association Not Found

From Dev

Simple Form not posting to DB Rails

From Dev

bootstrap modal with Simple Form Rails

From Dev

simple rails search form not working

From Dev

Error with simple_form on Rails

From Dev

Disabling form default behavior rails

From Dev

Rails form associations for simple_form