function webform_component_defaults in Webform 7.4
Same name and namespace in other branches
- 5.2 webform_components.inc \webform_component_defaults()
- 6.3 includes/webform.components.inc \webform_component_defaults()
- 6.2 webform_components.inc \webform_component_defaults()
- 7.3 includes/webform.components.inc \webform_component_defaults()
Populate a component with the defaults for that type.
4 calls to webform_component_defaults()
- WebformConditionalsTestCase::testWebformConditionals in tests/
WebformConditionalsTestCase.test - Test that required fields with no default value can't be submitted as-is.
- webform_component_edit_form_submit in includes/
webform.components.inc - Submit handler for webform_component_edit_form().
- webform_menu_component_load in ./
webform.module - Menu loader callback. Load a webform component if the given cid is a valid.
- webform_node_load in ./
webform.module - Implements hook_node_load().
File
- includes/
webform.components.inc, line 1203 - Webform module component handling.
Code
function webform_component_defaults(&$component) {
$defaults = webform_component_invoke($component['type'], 'defaults');
drupal_alter('webform_component_defaults', $defaults, $component['type']);
if (!empty($defaults)) {
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;
}
}
}
}