You are here

function webform_component_defaults in Webform 5.2

Same name and namespace in other branches
  1. 6.3 includes/webform.components.inc \webform_component_defaults()
  2. 6.2 webform_components.inc \webform_component_defaults()
  3. 7.4 includes/webform.components.inc \webform_component_defaults()
  4. 7.3 includes/webform.components.inc \webform_component_defaults()

Populate a component with the defaults for that type.

2 calls to webform_component_defaults()
webform_components in ./webform.module
Menu callback for node/[nid]/components.
webform_load in ./webform.module
Implementation of hook_load().

File

./webform_components.inc, line 582
Webform module components handling.

Code

function webform_component_defaults(&$component) {
  webform_load_components();
  $function = '_webform_defaults_' . $component['type'];
  if (function_exists($function)) {
    $defaults = $function();
    foreach ($defaults as $key => $default) {
      if (!isset($component[$key])) {
        $component[$key] = $default;
      }
    }
    foreach ($defaults['extra'] as $extra => $default) {
      if (!isset($component['extra'][$extra])) {
        $component['extra'][$extra] = $default;
      }
    }
  }
}