I'm having trouble working with disabled checkboxes.
I've tried two approaches. first:
= check_box "permissions", "permission_#{row}[create]", {checked: has_permission?(@user, permission, "create")}, 'true', 'false'
This checkbox is disabled inside of the view but also checked, but when submitted it's value in my params looks like this:
"create"=>"false"
So when I update my attributes, created is changed from true to false in my params.
How can I send true to my params instead of false, when a disabled checkbox is checked?
disabled
flag set to true so like this:<%= check_box "permissions", "permission_#{row}[create]", {checked: has_permission?(@user, permission, "create")}, 'true', 'false', disabled: true %>
. That might keep it out of your params. No guarantees though - MCBamatrue
for a disabled field you would either need to update the hidden field, or have your own hidden field to send you back the correct value. - FuzzyJulz