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

[eluser]coolgeek[/eluser]
Still generating a record with "test award" as the name and '0000-0-0' as the date. Here's the updated (and complete) copy of the validation library

Code:
<?php
class MY_Form_validation extends CI_Form_validation {

    function MY_Form_validation()
    {
        parent::CI_Form_validation();
    }

    function date_check ($str) {

        $day = $this->input->post('day');
        $month = $this->input->post('month');
        $year = $this->input->post('year');

        if (checkdate($month, $day, $year))
            return TRUE;
        else
        {
            $this->form_validation->set_message('date_check', 'The date field is invalid');
            return FALSE;
        }
    }

    function award_check($str)
    {
        if ($str == 'test award')
        {
            $this->form_validation->set_message('award_check', 'The %s field can not be the word "test award"');
            return FALSE;
        }
        else
        {
            //return TRUE;
            return 'wtf';
        }
    }
}

You'll note that I'm even trying to change the value in award_check in case the if failed for some bizarre reason. Also note that I've updated to accept a parameter in date_check, even though I'm not using it.

I am continuing to get (and fix) PHP errors flagged on MY_Form_validation.php when I've got a typo, so I am confident that CI_Form_validation is being extended

and yes, checkdate takes month first

http://us3.php.net/manual/en/function.checkdate.php


Messages In This Thread
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:08 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:13 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:16 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:24 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:27 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:35 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:38 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:42 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:43 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:58 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 06:05 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 06:20 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 06:33 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 12:21 PM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 12:24 PM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 12:49 PM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 01:31 PM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 01:38 PM
Form validation: Callback not changing the input value - by El Forum - 07-09-2009, 08:50 AM
Form validation: Callback not changing the input value - by El Forum - 07-09-2009, 11:20 AM
Form validation: Callback not changing the input value - by El Forum - 07-09-2009, 11:52 AM
Form validation: Callback not changing the input value - by El Forum - 07-09-2009, 11:59 AM
Form validation: Callback not changing the input value - by El Forum - 07-16-2009, 10:27 PM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 08:23 AM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 09:42 AM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 11:00 AM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 11:18 AM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 11:58 AM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 12:26 PM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 01:53 PM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 04:21 PM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 05:50 PM
Form validation: Callback not changing the input value - by El Forum - 09-03-2009, 12:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB