CodeIgniter Forums
Form Validation with Array for fieldname - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Form Validation with Array for fieldname (/thread-40326.html)



Form Validation with Array for fieldname - El Forum - 04-05-2011

[eluser]jrlooney[/eluser]
According to this, my form and validation should work
http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#arraysasfields

My form has form objects such as :

Code:
<input type="text" size="50" class="text" name="setting[client_name]" value="">

And my validate function includes :

Code:
$rules['setting[client_name]']    = "required";

$fields['setting[client_name]']    = 'Business Name';

But it errors even when a valid value exists in the post. How can I troubleshoot to insure that the fieldname being posted matches the fieldname being set in the validation rules/fields?


Form Validation with Array for fieldname - El Forum - 04-05-2011

[eluser]daniel ispas[/eluser]
Hi,

As far as i know you can't define validation rules that match the value of the field to a given string using the validation library included in CI. You could use a simple if statement or modify the validation class / create your own class.


Form Validation with Array for fieldname - El Forum - 04-05-2011

[eluser]jrlooney[/eluser]
sorry that makes no sense to me. I've been using CI for years now w/o issue. not sure why the validation config is not matching up to post values