function _name_render_component in Name Field 6
Same name and namespace in other branches
- 7 name.module \_name_render_component()
1 call to _name_render_component()
- name_element_expand in ./
name.module - The #process callback to create the element.
File
- ./
name.module, line 387 - Defines an API for displaying and inputing names.
Code
function _name_render_component($component, $name, $value, $core) {
$element = array(
'#attributes' => array(
'class' => 'name-element name-' . $name . ($core ? ' name-core-component' : ''),
),
);
if (isset($component['attributes'])) {
foreach ($component['attributes'] as $key => $attribute) {
if (!isset($element['#attributes'][$key])) {
$element['#attributes'][$key] = $attribute;
}
else {
$element['#attributes'][$key] .= ' ' . $attribute;
}
}
}
$base_attributes = array(
'type',
'title',
'size',
'maxlength',
);
foreach ($base_attributes as $key) {
$element['#' . $key] = $component[$key];
}
$element['#default_value'] = $value;
if ($component['type'] == 'select') {
$element['#options'] = $component['options'];
$element['#size'] = 1;
}
elseif (!empty($component['autocomplete'])) {
$element['#autocomplete_path'] = $component['autocomplete'];
}
// Enable the title options.
$element['#title_display'] = isset($component['title_display']) ? $component['title_display'] : 'description';
return $element;
}