function _webform_render_email in Webform 5
Same name and namespace in other branches
- 5.2 components/email.inc \_webform_render_email()
- 6.3 components/email.inc \_webform_render_email()
- 6.2 components/email.inc \_webform_render_email()
- 7.4 components/email.inc \_webform_render_email()
- 7.3 components/email.inc \_webform_render_email()
Build a form item array containing all the properties of this component.
Parameters
$component: An array of information describing the component, directly correlating to the webform_component database schema.
Return value
An array of a form item to be displayed on the client-side webform.
1 call to _webform_render_email()
- _webform_submission_display_email in components/
email.inc - Display the result of a textfield submission. The output of this function will be displayed under the "results" tab then "submissions".
File
- components/
email.inc, line 55
Code
function _webform_render_email($component) {
global $user;
$form_item = array(
'#type' => 'textfield',
'#title' => htmlspecialchars($component['name'], ENT_QUOTES),
'#required' => $component['mandatory'],
'#weight' => $component['weight'],
'#description' => _webform_filtervalues($component['extra']['description']),
'#attributes' => $component['extra']['attributes'],
'#prefix' => '<div class="webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '">',
'#suffix' => '</div>',
'#validate' => array(
'_webform_validate_email' => array(
'submitted][' . $component['cid'],
),
),
);
// Fill in the user's email address if available.
if ($user->uid && $user->mail && $component['value'] == 'user email') {
$form_item['#default_value'] = $user->mail;
}
// Change the 'width' option to the correct 'size' option.
if ($component['extra']['width'] > 0) {
$form_item['#size'] = $component['extra']['width'];
}
return $form_item;
}