Skip to content
  • Hans-Peter Deifel's avatar
    upload: Send correct form data in presence of checkboxes · 0ffecd03
    Hans-Peter Deifel authored
    tl;dr: Unchecked checkboxes usually don't send their value as
    parameter when the form is submitted. The ajax request in our upload
    code did just that which resulted in the value of checkboxes being
    wrongly interpreted.
    
    The default value of a checkbox is "on", even when it is off. The crux
    is that with standard HTML forms, this value will only be included in
    the form data if the checkbox is checked. The python end thus receives
    "on" for a checked checkbox and the empty string for an unchecked
    checkbox. It so happens that bool("on") == True and bool("") == False.
    
    Our JavaScript code that sends the form data for the upload page
    wrongly included the checkbox value, even if it was not checked. This
    resulted in the python end always receiving "on".
    
    See: http://stackoverflow.com/questions/33487360/formdata-and-checkboxes
    
    fixes #106
    0ffecd03