• Resolved imagospot

    (@imagospot)


    Hello,

    in version 2.4.0 and 2.4.1 there is bug with processing multiple required checkboxes.

    in simplr_build_form function in simplr_form_functions.php at 369 line:

    if(isset($data[$cf['key']])) {
    ...
    $key_val = $data[$cf['key']];
    }

    you are checking if value is posted and present in dictionary, but you don’t reset value of $key_val between multiple fields, that means if you check on checkbox all next checkboxes will be returned with invalid markup after validation.

    Proposed change:
    Add

    else {
       $key_val = '';
    }

    Or
    Create checkboxes with another hidden field.

    <input type="hidden" name="test" val="">
    <inputy type="checkbox" name="test" val="on">

    This ensures that there is always posted value, even if checkbox is not checked. Because browsers doesn’t send value for unchecked fields.

    Proof screenshots:
    https://i.imgur.com/TdcDUBc.png
    https://i.imgur.com/xKMoct6.png – checked only first field, returned form has all checkboxes checked
    https://i.imgur.com/xbNmT8U.png – checked only second field, returned form has all next checkboxes checked

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Invalid returned HTML with multiple required checkboxes’ is closed to new replies.