• 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_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: 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: Non-static method view::load() should not be called statically in /home1/eangkasa/public_html/sites/all/modules/views/views.module on line 879.

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

  1. function set_select($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 ' selected="selected"';
  13. }
  14. }
  15. elseif ($_POST[$field] == $value)
  16. {
  17. return ' selected="selected"';
  18. }
  19. }

 

2. Pay a closer attention on field name & id on listbox (select with multiple enabled) being displayed on the view file:

  1. <select id="business[]" name="business[]" size="10">
  2. </select>

Afterwards, $this->validation->set_select('business', $value) will be used to reselect the chosen values. At this point, if validation fails and the form is being reloaded to the user, then the multiple values previouly submitted will be reselected.

3. Last but not least, using $yourownvariable = $_POST["business"]; on the controller file will grab the array of submitted values and store it inside your own defined variable.