Repopulating checkboxes in Codeigniter after Unsuccessful Form Validation

前端 未结 9 773
梦毁少年i
梦毁少年i 2021-02-04 16:18

I have a problem repopulating a set of checkboxes after an unsuccessful form validation returns the user back to the same form. Dropdown menus and text inputs could be repopulat

9条回答
  •  深忆病人
    2021-02-04 16:41

    function set_checkbox_array($field, $value)
    {
        $arr = isset($_POST[$field]) ? $_POST[$field] : FALSE;
        return ($arr !== FALSE && is_array($arr) && in_array($value, $arr)) ? 'checked="checked"' : '';
    }
    

提交回复
热议问题