Welcome Guest, Not a member yet? Register   Sign In
Possible form validation bug?
#1

[eluser]TheFuzzy0ne[/eluser]
Hi everyone. I've been fighting with the form validation library for most of today. I've been trying to purify my HTML after calling a custom validation callback. In my mind, it should work, but in actuality, it doesn't. I've designed a simple test to illustrate what I'm talking about:

./system/application/controllers/test_form_validation
Code:
<?php

class Test_form_validation extends Controller
{
    
    function index()
    {
        // Load the form validation library.
        $this->load->library('form_validation');
        
        // Set the rules.
        $this->form_validation->set_rules('input', '', 'ltrim|callback__my_callback|rtrim');
        
        // Run validation.
        $this->form_validation->run();
        
        // Output the page.
        $this->output->set_output($this->get_view(TRUE));
    }
    
    function _my_callback()
    {
        // We'll just return TRUE so the test passes.
        return TRUE;
    }
    
    function get_view()
    {

        return <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;Form validation test&lt;/title&gt;
        &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8" /&gt;

    &lt;/head&gt;
    &lt;body&gt;
        <div>
            <code>
                content: "{$this->input->post('input')}"
            </code>
        </div>
        &lt;form action="" method="post"&gt;
            <div>
                <label>Input:
                    &lt;input type="text" name="input" value=" some text " /&gt;
                </label>
            </div>
            <div>
                &lt;input type="submit" name="submit" value="Submit" /&gt;
            </div>
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
EOT;
    }
}

In the case of the above, rtrim is never called. This is fixed if I make the field required, but this isn't a required field. Is this a bug, or am I missing something totally obvious here?


Messages In This Thread
Possible form validation bug? - by El Forum - 06-29-2009, 01:15 PM
Possible form validation bug? - by El Forum - 06-29-2009, 03:15 PM
Possible form validation bug? - by El Forum - 06-29-2009, 03:23 PM
Possible form validation bug? - by El Forum - 06-29-2009, 03:59 PM
Possible form validation bug? - by El Forum - 06-29-2009, 04:26 PM
Possible form validation bug? - by El Forum - 06-29-2009, 04:28 PM
Possible form validation bug? - by El Forum - 06-29-2009, 04:45 PM
Possible form validation bug? - by El Forum - 06-29-2009, 05:46 PM
Possible form validation bug? - by El Forum - 06-29-2009, 06:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB