Problem/Motivation

Was getting this error message:

Warning: Invalid argument supplied for foreach() in form_type_checkboxes_value() (line 2337 of html/includes/form.inc).

Traced it back to:

Default is not an array.

array ( '#type' => 'checkboxes', 
  '#title' => 'Demo regions', 
  '#options' => array ( 'navigation' => 'Navigation', 'header' => 'Header', 'help' => 'Help', 'content' => 'Content', 'sidebar_first' => 'Primary Sidebar', 'sidebar_second' => 'Secondary Sidebar', 'footer' => 'Footer', ), 

'#default_value' => '', // THIS needs to be an array.

'#input' => true, '#process' => array ( 0 => 'form_process_checkboxes', ), '#theme_wrappers' => array ( 0 => 'checkboxes', ), '#pre_render' => array ( 0 => 'form_pre_render_conditional_form_element', 1 => 'ctools_dependent_pre_render', ), '#defaults_loaded' => true, '#tree' => false, '#disabled' => false, '#parents' => array ( 0 => 'omega_demo_regions_list', ), '#array_parents' => array ( 0 => 'omega', 1 => 'development', 2 => 'settings', 3 => 'omega_demo_regions_list', 4 => 'omega_demo_regions_list', ), '#weight' => 0, '#processed' => false, '#required' => false, '#attributes' => array ( ), '#title_display' => 'before', '#id' => 'edit-omega-demo-regions-list--2', '#name' => 'omega_demo_regions_list', )

Proposed resolution

Cast the value to an array.

Remaining tasks

User interface changes

API changes

Comments

joelpittet’s picture

Status: Active » Needs review
StatusFileSize
new692 bytes
steinmb’s picture

Perhaps it is better to make sure that omega_theme_get_setting() return a empty array since that is what is expected?

steinmb’s picture

StatusFileSize
new514 bytes

Forgot the patch.

joelpittet’s picture

@steinmb it's not expecting array what is expected from the return value in the comment block.

 * @return mixed|null
 *   The value of the requested setting, or the $default value if the setting
 *   does not exist.

That's why I was suggesting just cast it because just that one thing expects an array, others could be TRUE, or 'string' or whatever theme setting is storing.

joelpittet’s picture

Status: Needs review » Needs work

Thanks for looking at this issue! It's been sitting for a while:)

steinmb’s picture

Status: Needs work » Reviewed & tested by the community

You are right, casting it to a array is just fine. Patch in #1 is RTBC to me.
Have been dusting off a lot of old issues, trying to learn Omega and figure out the state and stability of it compared to Zen.