function choices_field_widget_form in Poll Improved 7
Implements hook_field_widget_form().
File
- modules/
choices/ choices.module, line 145 - Defines simple choices field.
Code
function choices_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
switch ($instance['widget']['type']) {
case 'choices_default':
$main_widget = $element + array(
'#type' => 'textfield',
'#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : NULL,
'#size' => 60,
'#maxlength' => 255,
'#attributes' => array(
'class' => array(
'choices-text',
),
),
);
break;
case 'choices_submit_default':
$main_widget = $element + array(
'#type' => 'textfield',
'#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : t('Save'),
'#size' => 20,
'#maxlength' => 32,
'#attributes' => array(
'class' => array(
'choices-submit',
),
),
);
break;
}
if ($main_widget) {
$element['value'] = $main_widget;
}
return $element;
}