You are here

function _chosen_add_plugin_prefix in Chosen 7.3

Implementation of _chosen_add_plugin_prefix().

Helperfunction to refactor the fields array. Adds plugin namespaces to the fields. To be able to group them later on.

Parameters

$array: Field array.

$plugin_name: The actual plugin.

Return value

$new_array Array with plugin namespaces for the fields.

1 call to _chosen_add_plugin_prefix()
chosen_generate_forms in ./chosen.module
Implementation of chosen_generate_forms().

File

./chosen.module, line 513
General functions and hook implementations.

Code

function _chosen_add_plugin_prefix($array, $plugin_name) {
  foreach ($array as $key => $value) {
    if (isset($value['#default_value'])) {

      // Is field.
      $new_array[$plugin_name . '_' . $key] = $value;
    }
    else {
      if (!is_array($value)) {

        // Is value.
        $new_array[$key] = $value;
      }
      else {

        // Is child.
        $new_array[$key] = _chosen_add_plugin_prefix($value, $plugin_name);
      }
    }
  }
  return $new_array;
}