• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin

Please see the following forum thread topic as a possible bug and partial enhancement for the next release of Code Igniter


CI is not dealing with user submitted array values properly.

* You cannot validate listbox (select with multiple enabled), checkbox groups and reselect the user selected values using set_select, set_checkbox for multiple values

* You cannot use trim, htmlspecialchars or any other native php function in rules

* When you enable XSS_Clean in config.php error will pop-up when user select multiple values in list box or check checkbox groups ( ie: checking multiple checkboxes for hobbies in html form )

* You cannot use any other validation rules that CI provides like numeric, integer, xss_clean

What this post address:
This post address the following:

* Allowing to use trim, required, htmlspecialchars or any other native php function call in the rules.

* Allowing to use set_select, set_checkbox for listboxes and checkbox groups, checkboxgroupname_error, listboxname_error

Still you cannot use CI’s validation rules like integer, numeric, xss_clean for arrays. But I don’t think these validation will be needed for listboxes and checkbox groups as you are not going to store these values in db / re-display in html. Mostly, you will make use of the values from db / array to populate, validate against user submitted values.

But if you still need to validate for any purpose, you can call those functions in a loop for all the user selected values in a listbox / checkbox.

Enabling CI’s - Validation library to support list box and check box group is involve replacing the system’s Validation.php with our version. To enable this copy system/library/validation.php to application/library/ and do the necessary modification listed below.

Thanks to vadivelan for writing up the issues / extension to take care of this.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.