|
Lack of array support for listbox, checkbox in CodeIgniter version 1.6.3
|
For those people still having one of your sites using CodeIgniter version 1.6.3 and below, you will certainly informed that CI doesn't support validation of listbox (select with multiple enabled) and checkbox for reselecting multiple values chosen. However, there is a decent hack available to enable such requirement, elaborated as below:
You should apply this patch ONLY IF you're using CI version 1.6.3 and below, CI version 1.7.0 and above uses a new form validation class and it does support array as field names.
1. Modify the core Validation.php located under system/libraries/Validation.php, then replace 2 sets of function called as "set_checkbox" and "set_select".
How validation works and its callback function in Code Igniter
|
Validation framework in the Code Igniter is pretty powerful, i have to admit that once you get around to use it, eventually it can save lots of web development time, and it's much more secure rather than building it up yourself. CI provides a number of commonly used validation rules such as "required fields", "numeric fields", "alpha fields", and many others. Additionally, you can build up your own custom validation function by using callback. A comprehensive user guide from Code Igniter in regard to form validation is available here.
Notice: This Code Igniter is using version 1.6.3, there is currently a much newer version 1.7.2, and it's using a new form validation class instead, just a warning that the below code is dedicated solely for CI version 1.6.3 and below.
The sample code below will elaborate how CI validation works around the clock:
Code Igniter as an excellent PHP framework
|
For starter, i have been using Code Igniter for over a year and it was introduced by a friend of mine as he was explaining on how essential to have a PHP Framework to speed up your web development. I was doubt at that time, but after I tried it by myself for a couple of months, I was truly amazed on the fact that it does rapidly save your efforts and time.
Code Igniter is an open source PHP framework smilar to Zend and CakePHP if you know what i'm talking about. I would strongly recommend CI because it's lightweighted as compared to bloated Zend Framework. It introduces the idea of MVC (Model - View - Controller) approach in developing a website. For those PHP developers, you would normally put the whole HTML content, database connection and query, and PHP logic in one file with .php extension.
Now, what Code Igniter does, it separates the HTML content into "views" folder, database connection and query into "models" folder, and PHP logic into "controllers" folder. From my point of view, it gradually cleans up your code and makes it easy for web designers and developers to collaborate together, as a web designer should only need to modify the "views" folder, and there won't be any confusion in seeing PHP and/or MySQL code.

Web Development
Lack of array support for listbox, checkbox in CodeIgniter version 1.6.3

Recent comments