Welcome Guest, Not a member yet? Register   Sign In
Problem with set_value() of Form Validation
#2

[eluser]Aaron Wallentine[/eluser]
I had this exact same problem.

Basically, if you use set_value, and you use the Form_validation class, set_value() only actually returns the prepopulated value for fields that have validation rules set for them.

I looked into the source code of set_value and found this:

If you're not using the form_validation class, it just returns your $_POST data (after processing it through form_prep() ).
If you are using the form_validation class, it calls the set_value function from the form_validation object, which looks in its internal $_field_data array for the value. If it doesn't find it, it returns default.
I did a print_r on the _field_data array from there, and it appears that it only contains data of fields that have had validation rules defined on them,

So, if you want set_value to work for all your fields, it looks like you either:
1. Set up a validation rule for the field(s) in question
2. patch set_value() in form_validation.php to also check $_POST if it doesn't find the value in _field_data
3. don't load the form validation class

Should I file a bug report for this?

Or is this expected behavior? IE, if I'm using the form validation class, it's assumed that I have at least one rule set for all fields?


Messages In This Thread
Problem with set_value() of Form Validation - by El Forum - 03-28-2009, 06:59 PM
Problem with set_value() of Form Validation - by El Forum - 03-31-2009, 06:44 PM
Problem with set_value() of Form Validation - by El Forum - 05-19-2009, 07:11 AM
Problem with set_value() of Form Validation - by El Forum - 02-07-2010, 10:13 AM
Problem with set_value() of Form Validation - by El Forum - 05-30-2011, 04:31 PM
Problem with set_value() of Form Validation - by El Forum - 08-03-2011, 08:37 AM
Problem with set_value() of Form Validation - by El Forum - 08-03-2011, 03:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB