I have a form with input fields and a radio button. I am using a library which extends Form_validation class for resetting the input values, once form is submitted.
Code for MY_Form_validation.php:
if (!defined('BASEPATH')) exit('No direct script access allowed.');
class MY_Form_validation extends CI_Form_validation
{
public function MY_Form_validation()
{
parent::__construct();
}
public function unset_field_data()
{
unset($this->_field_data);
}
}
and it is working well for all input fields other than radio button.
I am creating radio button as:
<input type="radio" name="trailer" value="1" <?php echo set_radio('trailer', '1', TRUE); ?> />Yes
<input type="radio" name="trailer" value="0" <?php echo set_radio('trailer', '0'); ?> />No
Since I want to reset the radio values upon form errors.
I have successfully submitted the form and the form is getting cleared. But I am getting error next to the radio button in the form.
A PHP Error was encountered
Severity: Notice
Message: Undefined property: MY_Form_validation::$_field_data
Filename: libraries/Form_validation.php
Line Number: 807
checked="checked" />
I think this is because, the code doesn't resets radio buttons.