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

[eluser]rlaskey[/eluser]
[quote author="dmorin" date="1236369733"]@CroNiX
Very true. I'm not just setting a default value. What I'm doing is, if an email address field isn't provided/entered, I looking up the email address in my system based on other fields that are submitted. So it's a little more complicated than just adding a default value.

@Colin Williams
Doing what you suggested won't do anything unless the conditional surrounding it that checks if the key is already set in the post array is also removed. To understand why I'm "injecting" data into the POST, think about an API where some fields are optional. When people post to the API, they'll only include the fields they're interested in, leaving off the optional ones. So, if you need to do anything with those optional fields to validate the incoming parameters, it won't be possible to get those fields from the validation class.

I'm not really looking for work-arounds since I can come up with plenty on my own. I now believe this is a bug which is why I asked that it be move to the bug forum. Thanks[/quote]

I'm not sure if I'm hearing you right, though it seems that you're trying to pre-populate a field without the source of the data being from POST. I have a similar situation that I've dealt with in trying to pre-populate a form for an "edit" page. There is already data in the DB and there was not an initial POST, but I wanted to still use the set_checkbox() and other similar functions, since they seem to work pretty well. What I did was something like:

Code:
$attending_checked = array(2,3); // for simplicity; actual values derived via DB query/etc.
$this->form_validation->_field_data['attending[]'] = array('postdata' => $attending_checked);

It's probably not the best way to go about it, as it assumes that whatever data is in the DB / grabbing routines is clean, and is subverting some utility in the form validation library / form helper functions.. though it seems to work OK for me, and it gets the field data pre-populated properly.

If I am breaking protocol here, or if there are better, more accepted ways to go about this sort of thing, then please shout out. I don't, however, believe that there is necessarily a bug in the current system; more that there is included functionality which is not as explicit when it comes to this sort of situation.


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