function field_test_field_widget_form
Implements hook_field_widget_form().
File
-
modules/
field/ tests/ field_test.field.inc, line 189
Code
function field_test_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
switch ($instance['widget']['type']) {
case 'test_field_widget':
$element += array(
'#type' => 'textfield',
'#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : '',
);
return array(
'value' => $element,
);
case 'test_field_widget_multiple':
$values = array();
foreach ($items as $delta => $value) {
$values[] = $value['value'];
}
$element += array(
'#type' => 'textfield',
'#default_value' => implode(', ', $values),
'#element_validate' => array(
'field_test_widget_multiple_validate',
),
);
return $element;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.