function _wfm_component_generate in Webform Multiple (WFM) 7
Helper function to produce a render array for a repeatable Webform component.
1 call to _wfm_component_generate()
- _wfm_process_elements in ./
wfm.module - Process an element in the Webform to allow multiple values.
File
- ./
wfm.module, line 679 - Main module file for Webform Multiple (WFM).
Code
function _wfm_component_generate($component, $display = FALSE, $value = NULL, $format = 'html') {
$static_cache =& drupal_static(__FUNCTION__, array());
$key = $component['cid'] . "_{$format}";
if (isset($static_cache[$key]) && $value === NULL) {
return $static_cache[$key];
}
if ($display) {
$element = webform_component_invoke($component['type'], 'display', $component, $value, $format);
}
else {
$element = webform_component_invoke($component['type'], 'render', $component, $value);
// Reproduce Webform's behaviour from _webform_client_form_add_component();
// all elements are marked as validated already, which means normal Drupal
// form validation is bypassed. Webform does its own validation via
// webform_client_form_validate().
$element['#validated'] = TRUE;
$element['#webform_validated'] = FALSE;
}
$element['#webform_component'] = $component;
drupal_alter($display ? 'webform_component_display' : 'webform_component_render', $element, $component);
if ($value === NULL) {
$static_cache[$key] = $element;
}
return $element;
}