1

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Jenz
  • 8,280
  • 7
  • 44
  • 77
  • It is a property of field. I followed this post http://stackoverflow.com/questions/2802046/codeigniter-form-validation-how-to-unset-form-values-after-success – Jenz Mar 22 '14 at 07:52

1 Answers1

0

change this function to

public function MY_Form_validation() 
    {
        parent::__construct();
    }

to this

 function __construct() 
    {
        parent::__construct();
    }
Dexter
  • 1,804
  • 4
  • 24
  • 53