Welcome Guest, Not a member yet? Register   Sign In
Form Validation Class - Get validated values?
#1

[eluser]dmorin[/eluser]
How do you get the validated values from the new form validation class? For example, if I want to save the result to the database, how would I get the values for the queries? The old validation class created class vars for each field but this one doesn't seem to do that, or am I wrong?

I swear I can't find it in the manual.

Edit:
So, it looks like the preferred way is to just reference $_POST or $this->input->post() which seems odd since it destroys the original input, but regardless, might be a good thing to mention in the form_validation page of the user guide.

So my new problem is that apparently, when it repopulates $_POST with the validated data, it checks to see if that key already exists in the $_POST array. This breaks my app since I'm using a callback function to set a value in case that field doesn't exist. It seems as though if the Form_Validation class bothers to validate a field that isn't posted, it should probably repopulate a field that isn't posted.

If anyone thinks I'm doing this wrong, please let me know how you would do it. The other solution is to change this:
Code:
if (isset($_POST[$row['field']]))
{
    $_POST[$row['field']] = $this->prep_for_form($row['postdata']);
}
to
Code:
//if (isset($_POST[$row['field']]))
//{
    $_POST[$row['field']] = $this->prep_for_form($row['postdata']);
//}

Please let me know if you are aware of this breaking anything. Thanks.


Messages In This Thread
Form Validation Class - Get validated values? - by El Forum - 03-05-2009, 07:37 PM
Form Validation Class - Get validated values? - by El Forum - 03-05-2009, 08:49 PM
Form Validation Class - Get validated values? - by El Forum - 03-05-2009, 09:01 PM
Form Validation Class - Get validated values? - by El Forum - 03-05-2009, 09:24 PM
Form Validation Class - Get validated values? - by El Forum - 03-05-2009, 09:30 PM
Form Validation Class - Get validated values? - by El Forum - 03-05-2009, 09:39 PM
Form Validation Class - Get validated values? - by El Forum - 03-05-2009, 09:46 PM
Form Validation Class - Get validated values? - by El Forum - 03-05-2009, 09:56 PM
Form Validation Class - Get validated values? - by El Forum - 03-05-2009, 09:58 PM
Form Validation Class - Get validated values? - by El Forum - 03-05-2009, 10:23 PM
Form Validation Class - Get validated values? - by El Forum - 03-06-2009, 08:02 AM
Form Validation Class - Get validated values? - by El Forum - 03-06-2009, 08:15 AM
Form Validation Class - Get validated values? - by El Forum - 03-06-2009, 11:51 AM
Form Validation Class - Get validated values? - by El Forum - 03-07-2009, 03:42 PM
Form Validation Class - Get validated values? - by El Forum - 03-07-2009, 03:58 PM
Form Validation Class - Get validated values? - by El Forum - 03-08-2009, 11:18 AM
Form Validation Class - Get validated values? - by El Forum - 03-08-2009, 11:26 AM
Form Validation Class - Get validated values? - by El Forum - 03-08-2009, 11:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB