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

[eluser]rlaskey[/eluser]
[quote author="dmorin" date="1236551195"]Ah, I see what you mean and I agree that accessing _field_data directly can be useful for interacting with the form validation library. However, for php4 compatibility, CI prefixes things with _ to indicate that they should be private in nature, and accessing the private components of a class in order to get it to behave the way you need violates some oo principles such as encapsulation.

It is odd though that the helpers reference this array instead of using setters and getters. Not the best bit of code IMHO.[/quote]

Right, exactly. This is in part what I mean by a lack of functionality, rather than a bug. For future versions of CI it would help, I think, to have some alternate functions which provide access to this private variable via different methods. The current scheme is fairly limited to POST data coming in, processing it, and then spitting the result straight back out. If there are other sources, which is essentially what you'd like to implement, the current functions are too restrictive to allow incoming information unless you access this private variable rather directly.

Currently, there is the vehicle to extend libraries using your own functions, etc., and this may be the right way around the solution. In future versions of CI, however, it'd be nice to see some of this functionality included in the core. Something like a MY_Form_validator.php, w/ a function something like add_nonpost_variable_and_run() .. if that makes sense. This function would access the private _field_data variable, tack on whatever variables you'd like to the array (i.e., the email address from the DB that you pull out) formatted by way that complies with the standard _field_data, and then run the validations to make sure everything checks out.


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