Welcome Guest, Not a member yet? Register   Sign In
Form Validation library effects set_checkbox() and set_radio().
#1

[eluser]chadwhitaker[/eluser]
I have found that if you are running the Form Validation library if will prevent set_checkbox() and set_radio() functions from working.

Use the following controller to test my theory.

First run it as is, and test that the check box state is saved when submitting the form.

Then uncomment out "$this->load->library('form_validation');" and test it again, you will see that the checkbox state will not be remembered.

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test extends CI_Controller {
    
    public function __construct()
    {
        parent::__construct();
                    
    }

    function index()
    {
        //$this->load->library('form_validation');
        $this->load->helper('form');
    
        echo form_open();
    
        echo '<input type="checkbox" name="tester" value="hello world" id="tester" '.set_checkbox('tester', 'hello world').'/>';
    
        echo form_submit('go', 'Give it a test!');
    
        echo form_close();
    }
    
}
#2

[eluser]toopay[/eluser]
Its because the form helper take validation object if you load form validation library. Look at form_helper.php, at related function you referring...




Theme © iAndrew 2016 - Forum software by © MyBB