Welcome Guest, Not a member yet? Register   Sign In
Customizing Callback functions
#1

[eluser]Unknown[/eluser]
Can I pass variables to validation CAllback functions?
#2

[eluser]bretticus[/eluser]
No you cannot. BUT you can get post variables within your callback method.

To demonstrate:

Controller:
Code:
class Testing extends Controller        

    function test()
    {
        $this->form_validation->set_rules('one',   'One',    'trim|required|callback__test');
        $this->form_validation->set_rules('two',   'Two',    'trim|required');


        if ($this->form_validation->run() == FALSE) {
               $this->load->view('test');
        }
    }

    function _test($one)
    {
        echo "ONE: $one <br>";
        echo "TWO: " . $this->input->post('two') . " <br>";
    }
}

View: view.php
Code:
&lt;html&gt;
    &lt;head&gt;

        &lt;TITLE&gt;Hello&lt;/TITLE&gt;
    &lt;/head&gt;
    &lt;body&gt;

        &lt;?=form_open('testing/test')?&gt;

        &lt;?=form_input('one')?&gt;
        &lt;?=form_input('two')?&gt;

        &lt;?=form_submit('submit', 'submit')?&gt;

        &lt;?=form_close()?&gt;

    &lt;/body&gt;
&lt;/html&gt;
#3

[eluser]lifo101[/eluser]
I got this to work on my implementation: http://ellislab.com/forums/viewthread/121221/#600693 - but there are mixed results with at least one other user.




Theme © iAndrew 2016 - Forum software by © MyBB