Welcome Guest, Not a member yet? Register   Sign In
Form validation: Callback not changing the input value
#11

[eluser]Nis Sarup[/eluser]
I can always hack redux-auth to do what I want in the meantime.
I hate it when stuff don't want to do what it's supposed to do Smile

Thanks for your help so far Smile
#12

[eluser]TheFuzzy0ne[/eluser]
Hi there. I had an epiphany whilst walking to my friends house, and I think I've found you're problem. You're using the validation library, which is deprecated. You should be using the form_validation library. I'd also suggest you recheck your callback logic to make sure the date is actually valid. Here are a few examples of dates that would be valid with your callback:

00-00-00 - Obvious Wink
32-13-00 - No month has 32 days (although I wish they did, since there's never enough time).
30-02-09 - February never has 30 days

I'd suggest you add some extra checking in there to ensure that the date is valid. Smile

Hope this helps.
#13

[eluser]Nis Sarup[/eluser]
Aha! Now we're cooking with gas!
Thought it was something like that.

I'll rebuild it using the right library.
And using some extra checking Smile
#14

[eluser]Nis Sarup[/eluser]
Everything is working swimmingly now.
I don't know how, but it seems I had gotten into this page: http://ellislab.com/codeigniter/user-gui...ation.html instead of http://ellislab.com/codeigniter/user-gui...ation.html
#15

[eluser]TheFuzzy0ne[/eluser]
I'm glad everything is working now. Sometimes a problem can be seriously frustrating, although the solution is simple yet easily overlooked.
#16

[eluser]Nis Sarup[/eluser]
Those are the most frustrating problems, and the ones that takes the most time to solve.

About the User Guide, shouldn't it be stated somewhere on the page for validate (not form_validate) that it is deprecated?
There are a few pages, 4 according to google, that links directly to that page.
#17

[eluser]TheFuzzy0ne[/eluser]
I agree. There should be something at the top of the page in big red writing. Feel free to report it as a documentation bug.
#18

[eluser]Nis Sarup[/eluser]
Woot! I get to report a documentation bug! Smile
#19

[eluser]bhogg[/eluser]
I have a situation where the callback is not causing the form validation to fail:

Code:
public function form()
    {
        $this->load->helper('form');

        $this->load->view('login/form');
    }

    public function attempt()
    {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username',
                'Email Address / Username', 'trim|required');
        $this->form_validation->set_rules('password',
                'Password', 'required|callback__login');

        if ($this->form_validation->run() === FALSE)
        {
            $this->form();
        }
        else
        {
            die('apparently valid');
        }
    }

    public function _login($password)
    {
        get_instance()->form_validation->set_message('_login',
                'Incorrect email address or password.');

        return FALSE;
    }

If you leave the username and password blank you get errors, but the callback function is not causing a failure (when obviously it always should in it's current state). I've put debug code in the _login callback and it is being called when it should.

Something I'm missing?

EDIT: Have also done $this-> instead of get_instance() in the _login function, same effect...
#20

[eluser]TheFuzzy0ne[/eluser]
I can't see any problems. Have you overridden the form validation library at all? What version of CodeIgniter are you using?




Theme © iAndrew 2016 - Forum software by © MyBB