The set_value(‘field name’) function in codeigniter allows us to retain the value of input field in form during form submission but it’s not applicable to keep checkbox checked if it was checked while the form was submitted or during postback submit refresh. Here to keep checkbox checked after form submit in Codeigniter, the set_checkbox() function plays the role.
Checkbox validation in Codeigniter form is not as straight as validating other input types. As usually we need to check if a checkbox is checked or unchecked during form submission likewise if user accepted or not ‘TOS (Terms of Services)’ through checkbox. So I have provided a form validation rule to validate checkbox as ‘required’ rule can’t do the task.