You are here

function patterns_options_flatten in Patterns 6

Same name and namespace in other branches
  1. 6.2 patterns.module \patterns_options_flatten()
  2. 7.2 includes/unused.inc \patterns_options_flatten()
  3. 7 includes/unused.inc \patterns_options_flatten()

Helper function to flatter options, but keep the title/names in

1 call to patterns_options_flatten()
patterns_sync_form_values in ./patterns.module
Make some modifications to the form values based on the form In particular, make sure form elements with #options and #multiple set the keys of the array as the key of the value as how FAPI does it, but XML of course does not.

File

./patterns.module, line 2434
Enables extremely simple adding/removing features to your site with minimal to no configuration

Code

function patterns_options_flatten($array, $reset = TRUE) {
  static $return;
  if ($reset) {
    $return = array();
  }
  foreach ($array as $key => $value) {
    if (is_object($value)) {
      patterns_options_flatten($value->option, FALSE);
    }
    else {
      if (is_array($value)) {
        patterns_options_flatten($value, FALSE);
      }
      else {
        $return[$key] = $value;
      }
    }
  }
  return $return;
}