function name_widget_settings in Name Field 6
Implementation of hook_widget_settings().
File
- ./
name.module, line 910 - Defines an API for displaying and inputing names.
Code
function name_widget_settings($op, $widget) {
switch ($op) {
case 'form':
$form = array();
$form['instance_settings'] = array(
'#tree' => TRUE,
);
_name_defaults($widget, 'instance_settings');
$components = _name_translations();
$form['instance_settings']['size'] = array();
$form['instance_settings']['title_display'] = array();
foreach ($components as $key => $title) {
$form['instance_settings']['size'][$key] = array(
'#type' => 'textfield',
'#title' => t('HTML size property for !title', array(
'!title' => $title,
)),
'#default_value' => $widget['instance_settings']['size'][$key],
'#required' => FALSE,
'#size' => 10,
'#description' => t('The maximum length of the field in characters. This must be between 1 and 255.'),
'#element_validate' => array(
'_name_validate_integer_positive',
),
);
$form['instance_settings']['title_display'][$key] = array(
'#type' => 'radios',
'#title' => t('Label display for !title', array(
'!title' => $title,
)),
'#default_value' => $widget['instance_settings']['title_display'][$key],
'#options' => array(
'title' => t('above'),
'description' => t('below'),
'none' => t('hidden'),
),
'#description' => t('This controls how the label of the name component is displayed in the form.'),
);
$form['instance_settings']['inline_css_enabled'][$key] = array(
'#type' => 'checkbox',
'#title' => t('Use inline styles for !title', array(
'!title' => $title,
)),
'#default_value' => $widget['instance_settings']['inline_css_enabled'][$key],
);
}
$form['instance_settings']['title_field'] = array(
'#type' => 'radios',
'#title' => t('Title field type'),
'#default_value' => $widget['instance_settings']['title_field'],
'#required' => TRUE,
'#options' => array(
'select' => t('Drop-down'),
),
);
$form['instance_settings']['generational_field'] = array(
'#type' => 'radios',
'#title' => t('Generational field type'),
'#default_value' => $widget['instance_settings']['generational_field'],
'#required' => TRUE,
'#options' => array(
'select' => t('Drop-down'),
),
);
$form['instance_settings']['inline_css'] = array(
'#type' => 'fieldset',
'#title' => t('Inline CSS styles for name components'),
'#description' => t('This gives you the option of specifying CSS rules to control the width of the name components. The HTML size for the component is used with the multiplier and the resulting width is rendered as an inline style such as: <em>style="width: 345px;"</em>'),
);
$form['instance_settings']['inline_css']['multiplier'] = array(
'#type' => 'textfield',
'#title' => t('Multiplier'),
'#default_value' => $widget['instance_settings']['inline_css']['multiplier'],
'#required' => TRUE,
'#description' => t('The width is set by multipling the HTML size with this.'),
);
$form['instance_settings']['inline_css']['unit'] = array(
'#type' => 'radios',
'#title' => t('CSS Unit'),
'#default_value' => $widget['instance_settings']['inline_css']['unit'],
'#required' => TRUE,
'#options' => array(
'em' => 'em',
'px' => 'px',
),
);
return $form;
case 'save':
return array(
'instance_settings',
);
}
}