• strict warning: Non-static method view::load() should not be called statically in /home1/eangkasa/public_html/sites/all/modules/views/views.module on line 879.
  • strict warning: Declaration of views_handler_argument::init() should be compatible with views_handler::init(&$view, $options) in /home1/eangkasa/public_html/sites/all/modules/views/handlers/views_handler_argument.inc on line 745.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home1/eangkasa/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 589.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home1/eangkasa/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 589.
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home1/eangkasa/public_html/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 149.
  • strict warning: Declaration of views_handler_filter_term_node_tid::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home1/eangkasa/public_html/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc on line 303.
  • strict warning: Declaration of views_plugin_style_default::options() should be compatible with views_object::options() in /home1/eangkasa/public_html/sites/all/modules/views/plugins/views_plugin_style_default.inc on line 25.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home1/eangkasa/public_html/sites/all/modules/views/plugins/views_plugin_row.inc on line 135.
  • strict warning: Declaration of views_plugin_row::options_submit() should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home1/eangkasa/public_html/sites/all/modules/views/plugins/views_plugin_row.inc on line 135.
  • strict warning: Non-static method view::load() should not be called statically in /home1/eangkasa/public_html/sites/all/modules/views/views.module on line 879.
  • strict warning: Declaration of views_handler_filter_node_status::operator_form() should be compatible with views_handler_filter::operator_form(&$form, &$form_state) in /home1/eangkasa/public_html/sites/all/modules/views/modules/node/views_handler_filter_node_status.inc on line 14.
  • strict warning: Non-static method view::load() should not be called statically in /home1/eangkasa/public_html/sites/all/modules/views/views.module on line 879.
  • warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home1/eangkasa/public_html/sites/all/modules/counter/counter.module on line 136.
  • warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home1/eangkasa/public_html/sites/all/modules/counter/counter.module on line 159.
  • warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home1/eangkasa/public_html/sites/all/modules/counter/counter.module on line 159.
  • strict warning: Non-static method view::load() should not be called statically in /home1/eangkasa/public_html/sites/all/modules/views/views.module on line 879.
  • strict warning: Declaration of views_handler_field_comment::init() should be compatible with views_handler_field::init(&$view, $options) in /home1/eangkasa/public_html/sites/all/modules/views/modules/comment/views_handler_field_comment.inc on line 50.
  • strict warning: Declaration of views_handler_field_comment_username::init() should be compatible with views_handler_field::init(&$view, $options) in /home1/eangkasa/public_html/sites/all/modules/views/modules/comment/views_handler_field_comment_username.inc on line 48.
  • strict warning: Non-static method view::load() should not be called statically in /home1/eangkasa/public_html/sites/all/modules/views/views.module on line 879.
  • strict warning: Non-static method view::load() should not be called statically in /home1/eangkasa/public_html/sites/all/modules/views/views.module on line 879.

Web Development

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".

  1. function set_checkbox($field = '', $value = '')
  2. {
  3. if ($field == '' OR $value == '' OR ! isset($_POST[$field]))
  4. {
  5. return '';
  6. }
  7.  
  8. if(is_array($_POST[$field]))
  9. {
  10. if(in_array($value,$_POST[$field]))
  11. {
  12. return ' checked="checked"';
  13. }
  14. }
  15. elseif ($_POST[$field] == $value)
  16. {
  17. return ' checked="checked"';
  18. }
  19. }

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.

Syndicate content