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

[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

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.

[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

[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

I'm glad everything is working now. Sometimes a problem can be seriously frustrating, although the solution is simple yet easily overlooked.

[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.

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.

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

I have a situation where the callback is not causing the form validation to fail:

public function form()


    public function attempt()
                'Email Address / Username', 'trim|required');
                'Password', 'required|callback__login');

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

    public function _login($password)
                '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...

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