Guest User

Untitled

a guest
Feb 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. checkbox_control :is_searchable, :label => "Allow other #{SITE_NAME} members to search for me and view me on the members page?"
  2.  
  3. # Generates this:
  4.  
  5. <input type="checkbox" id="user_is_searchable" value="1" name="user[is_searchable]" class="checkbox" checked="checked"/>
  6. <input type="hidden" value="0" name="user[is_searchable]" class="hidden"/>
  7. <label for="user_is_searchable">Send me weekly motivator reports?</label>
  8.  
  9. # When this is submitted to the controller I get:
  10.  
  11. { "user" => { "is_searchable" => "0" } }
  12.  
  13. # Even if the checkbox is checked?
  14.  
  15. # I can solve this by simply reversing the order of the hidden checkbox field. Like so:
  16.  
  17. <input type="hidden" value="0" name="user[is_searchable]" class="hidden"/>
  18. <input type="checkbox" id="user_is_searchable" value="1" name="user[is_searchable]" class="checkbox" checked="checked"/>
  19. <label for="user_is_searchable">Send me weekly motivator reports?</label>
Add Comment
Please, Sign In to add comment