- Patch #567064 by yched, sun: widgets done 'the easy way' have too many limitations. Removes more code than it adds!
parent
e4ca439ba1
commit
342ebd7776
|
|
@ -632,11 +632,15 @@ function hook_field_widget_info_alter(&$info) {
|
||||||
* Array of default values for this field.
|
* Array of default values for this field.
|
||||||
* @param $delta
|
* @param $delta
|
||||||
* The order of this item in the array of subelements (0, 1, 2, etc).
|
* The order of this item in the array of subelements (0, 1, 2, etc).
|
||||||
|
* @param $element
|
||||||
|
* A form element array containing basic properties for the widget: #title,
|
||||||
|
* #description, #required, #field, #field_instance, #field_name, #delta,
|
||||||
|
* #columns.
|
||||||
* @return
|
* @return
|
||||||
* The form item for a single element for this field.
|
* The form item for a single element for this field.
|
||||||
*/
|
*/
|
||||||
function hook_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
|
function hook_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
|
||||||
$element = array(
|
$element += array(
|
||||||
'#type' => $instance['widget']['type'],
|
'#type' => $instance['widget']['type'],
|
||||||
'#default_value' => isset($items[$delta]) ? $items[$delta] : '',
|
'#default_value' => isset($items[$delta]) ? $items[$delta] : '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -57,18 +57,18 @@ function field_default_form($obj_type, $object, $field, $instance, $langcode, $i
|
||||||
$delta = isset($get_delta) ? $get_delta : 0;
|
$delta = isset($get_delta) ? $get_delta : 0;
|
||||||
$function = $instance['widget']['module'] . '_field_widget';
|
$function = $instance['widget']['module'] . '_field_widget';
|
||||||
if (function_exists($function)) {
|
if (function_exists($function)) {
|
||||||
if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta)) {
|
$element = array(
|
||||||
$defaults = array(
|
'#object_type' => $instance['object_type'],
|
||||||
'#required' => $get_delta > 0 ? FALSE : $instance['required'],
|
'#bundle' => $instance['bundle'],
|
||||||
'#columns' => array_keys($field['columns']),
|
'#field_name' => $field['field_name'],
|
||||||
'#title' => check_plain(t($instance['label'])),
|
'#columns' => array_keys($field['columns']),
|
||||||
'#description' => field_filter_xss($instance['description']),
|
'#title' => check_plain(t($instance['label'])),
|
||||||
'#delta' => $delta,
|
'#description' => field_filter_xss($instance['description']),
|
||||||
'#field_name' => $field['field_name'],
|
// Only the first widget should be required.
|
||||||
'#bundle' => $instance['bundle'],
|
'#required' => $delta == 0 && $instance['required'],
|
||||||
'#object_type' => $instance['object_type'],
|
'#delta' => $delta,
|
||||||
);
|
);
|
||||||
$element = array_merge($element, $defaults);
|
if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element)) {
|
||||||
// If we're processing a specific delta value for a field where the
|
// If we're processing a specific delta value for a field where the
|
||||||
// field module handles multiples, set the delta in the result.
|
// field module handles multiples, set the delta in the result.
|
||||||
// For fields that handle their own processing, we can't make assumptions
|
// For fields that handle their own processing, we can't make assumptions
|
||||||
|
|
@ -84,14 +84,6 @@ function field_default_form($obj_type, $object, $field, $instance, $langcode, $i
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($form_element) {
|
if ($form_element) {
|
||||||
$defaults = array(
|
|
||||||
'#field_name' => $field['field_name'],
|
|
||||||
'#tree' => TRUE,
|
|
||||||
'#weight' => $instance['widget']['weight'],
|
|
||||||
);
|
|
||||||
|
|
||||||
$form_element = array_merge($form_element, $defaults);
|
|
||||||
|
|
||||||
// Add the field form element as a child keyed by language code to match the
|
// Add the field form element as a child keyed by language code to match the
|
||||||
// field data structure: $object->{$field_name}[$langcode][$delta][$column].
|
// field data structure: $object->{$field_name}[$langcode][$delta][$column].
|
||||||
// The '#language' key can be used to access the field's form element when
|
// The '#language' key can be used to access the field's form element when
|
||||||
|
|
@ -99,7 +91,7 @@ function field_default_form($obj_type, $object, $field, $instance, $langcode, $i
|
||||||
// form element.
|
// form element.
|
||||||
$addition[$field['field_name']] = array(
|
$addition[$field['field_name']] = array(
|
||||||
'#tree' => TRUE,
|
'#tree' => TRUE,
|
||||||
'#weight' => $form_element['#weight'],
|
'#weight' => $instance['widget']['weight'],
|
||||||
'#language' => $langcode,
|
'#language' => $langcode,
|
||||||
$langcode => $form_element,
|
$langcode => $form_element,
|
||||||
);
|
);
|
||||||
|
|
@ -145,6 +137,7 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form,
|
||||||
|
|
||||||
$form_element = array(
|
$form_element = array(
|
||||||
'#theme' => 'field_multiple_value_form',
|
'#theme' => 'field_multiple_value_form',
|
||||||
|
'#field_name' => $field['field_name'],
|
||||||
'#cardinality' => $field['cardinality'],
|
'#cardinality' => $field['cardinality'],
|
||||||
'#title' => $title,
|
'#title' => $title,
|
||||||
'#required' => $instance['required'],
|
'#required' => $instance['required'],
|
||||||
|
|
@ -157,21 +150,21 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form,
|
||||||
$function = $instance['widget']['module'] . '_field_widget';
|
$function = $instance['widget']['module'] . '_field_widget';
|
||||||
if (function_exists($function)) {
|
if (function_exists($function)) {
|
||||||
for ($delta = 0; $delta <= $max; $delta++) {
|
for ($delta = 0; $delta <= $max; $delta++) {
|
||||||
if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta)) {
|
$multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
|
||||||
$multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
|
$element = array(
|
||||||
$defaults = array(
|
'#object_type' => $instance['object_type'],
|
||||||
// For multiple fields, title and description are handled by the wrapping table.
|
'#bundle' => $instance['bundle'],
|
||||||
'#title' => $multiple ? '' : $title,
|
'#field_name' => $field_name,
|
||||||
'#description' => $multiple ? '' : $description,
|
'#columns' => array_keys($field['columns']),
|
||||||
'#required' => $delta == 0 && $instance['required'],
|
// For multiple fields, title and description are handled by the wrapping table.
|
||||||
'#weight' => $delta,
|
'#title' => $multiple ? '' : $title,
|
||||||
'#delta' => $delta,
|
'#description' => $multiple ? '' : $description,
|
||||||
'#columns' => array_keys($field['columns']),
|
// Only the first widget should be required.
|
||||||
'#field_name' => $field_name,
|
'#required' => $delta == 0 && $instance['required'],
|
||||||
'#object_type' => $instance['object_type'],
|
'#delta' => $delta,
|
||||||
'#bundle' => $instance['bundle'],
|
'#weight' => $delta,
|
||||||
);
|
);
|
||||||
|
if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element)) {
|
||||||
// Input field for the delta (drag-n-drop reordering).
|
// Input field for the delta (drag-n-drop reordering).
|
||||||
if ($multiple) {
|
if ($multiple) {
|
||||||
// We name the element '_weight' to avoid clashing with elements
|
// We name the element '_weight' to avoid clashing with elements
|
||||||
|
|
@ -184,14 +177,12 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form,
|
||||||
'#weight' => 100,
|
'#weight' => 100,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
$form_element[$delta] = $element;
|
||||||
$form_element[$delta] = array_merge($element, $defaults);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add 'add more' button, if not working with a programmed form.
|
// Add 'add more' button, if not working with a programmed form.
|
||||||
if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED && empty($form_state['programmed'])) {
|
if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED && empty($form_state['programmed'])) {
|
||||||
|
|
||||||
$form_element[$field_name . '_add_more'] = array(
|
$form_element[$field_name . '_add_more'] = array(
|
||||||
'#type' => 'submit',
|
'#type' => 'submit',
|
||||||
'#name' => $field_name . '_add_more',
|
'#name' => $field_name . '_add_more',
|
||||||
|
|
|
||||||
|
|
@ -313,37 +313,9 @@ function number_element_info() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement hook_field_widget().
|
* Implement hook_field_widget().
|
||||||
*
|
|
||||||
* Attach a single form element to the form. It will be built out and
|
|
||||||
* validated in the callback(s) listed in hook_element_info(). We build it
|
|
||||||
* out in the callbacks rather than here in hook_widget so it can be
|
|
||||||
* plugged into any module that can provide it with valid
|
|
||||||
* $field information.
|
|
||||||
*
|
|
||||||
* Field module will set the weight, field name and delta values
|
|
||||||
* for each form element.
|
|
||||||
*
|
|
||||||
* If there are multiple values for this field, the Field module will
|
|
||||||
* call this function as many times as needed.
|
|
||||||
*
|
|
||||||
* @param $form
|
|
||||||
* the entire form array, $form['#node'] holds node information
|
|
||||||
* @param $form_state
|
|
||||||
* the form_state, $form_state['values'] holds the form values.
|
|
||||||
* @param $field
|
|
||||||
* The field structure.
|
|
||||||
* @param $instance
|
|
||||||
* the field instance array
|
|
||||||
* @param $langcode
|
|
||||||
* The language associated to $items.
|
|
||||||
* @param $delta
|
|
||||||
* the order of this item in the array of subelements (0, 1, 2, etc)
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* the form item for a single element for this field
|
|
||||||
*/
|
*/
|
||||||
function number_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
|
function number_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
|
||||||
$element = array(
|
$element += array(
|
||||||
'#type' => $instance['widget']['type'],
|
'#type' => $instance['widget']['type'],
|
||||||
'#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
|
'#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -94,8 +94,8 @@ function options_element_info() {
|
||||||
/**
|
/**
|
||||||
* Implement hook_field_widget().
|
* Implement hook_field_widget().
|
||||||
*/
|
*/
|
||||||
function options_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = NULL) {
|
function options_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
|
||||||
$element = array(
|
$element += array(
|
||||||
'#type' => $instance['widget']['type'],
|
'#type' => $instance['widget']['type'],
|
||||||
'#default_value' => !empty($items) ? $items : array(),
|
'#default_value' => !empty($items) ? $items : array(),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -563,40 +563,9 @@ function text_element_info() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement hook_field_widget().
|
* Implement hook_field_widget().
|
||||||
*
|
|
||||||
* Attach a single form element to the form. It will be built out and
|
|
||||||
* validated in the callback(s) listed in hook_element_info(). We build it
|
|
||||||
* out in the callbacks rather than here in hook_field_widget so it can be
|
|
||||||
* plugged into any module that can provide it with valid
|
|
||||||
* $field information.
|
|
||||||
*
|
|
||||||
* Field module will set the weight, field name and delta values
|
|
||||||
* for each form element.
|
|
||||||
*
|
|
||||||
* If there are multiple values for this field, the field module will
|
|
||||||
* call this function as many times as needed.
|
|
||||||
*
|
|
||||||
* @param $form
|
|
||||||
* the entire form array, $form['#node'] holds node information
|
|
||||||
* @param $form_state
|
|
||||||
* the form_state, $form_state['values'][$field['field_name']]
|
|
||||||
* holds the field's form values.
|
|
||||||
* @param $field
|
|
||||||
* The field structure.
|
|
||||||
* @param $instance
|
|
||||||
* the field instance array
|
|
||||||
* @param $langcode
|
|
||||||
* The language associated to $items.
|
|
||||||
* @param $items
|
|
||||||
* array of default values for this field
|
|
||||||
* @param $delta
|
|
||||||
* the order of this item in the array of subelements (0, 1, 2, etc)
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* the form item for a single element for this field
|
|
||||||
*/
|
*/
|
||||||
function text_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
|
function text_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
|
||||||
$element = array(
|
$element += array(
|
||||||
'#type' => $instance['widget']['type'],
|
'#type' => $instance['widget']['type'],
|
||||||
'#default_value' => isset($items[$delta]) ? $items[$delta] : '',
|
'#default_value' => isset($items[$delta]) ? $items[$delta] : '',
|
||||||
);
|
);
|
||||||
|
|
@ -721,7 +690,6 @@ function text_textarea_with_summary_process($element, $form_state, $form) {
|
||||||
'#weight' => 0,
|
'#weight' => 0,
|
||||||
'#title' => t('Summary'),
|
'#title' => t('Summary'),
|
||||||
'#description' => t('Leave blank to use trimmed value of full text as the summary.'),
|
'#description' => t('Leave blank to use trimmed value of full text as the summary.'),
|
||||||
'#required' => $element['#required'],
|
|
||||||
'#display' => $display,
|
'#display' => $display,
|
||||||
'#attached' => array('js' => array(drupal_get_path('module', 'text') . '/text.js')),
|
'#attached' => array('js' => array(drupal_get_path('module', 'text') . '/text.js')),
|
||||||
'#attributes' => array('class' => array('text-textarea-summary')),
|
'#attributes' => array('class' => array('text-textarea-summary')),
|
||||||
|
|
@ -738,7 +706,6 @@ function text_textarea_with_summary_process($element, $form_state, $form) {
|
||||||
'#title' => $display ? t('Full text') : $element['#title'],
|
'#title' => $display ? t('Full text') : $element['#title'],
|
||||||
'#description' => $element['#description'],
|
'#description' => $element['#description'],
|
||||||
'#required' => $element['#required'],
|
'#required' => $element['#required'],
|
||||||
'#required' => $instance['required'],
|
|
||||||
'#attributes' => array('class' => array('text-full-textarea')),
|
'#attributes' => array('class' => array('text-full-textarea')),
|
||||||
'#prefix' => '<div class="text-full-wrapper">',
|
'#prefix' => '<div class="text-full-wrapper">',
|
||||||
'#suffix' => '</div>',
|
'#suffix' => '</div>',
|
||||||
|
|
|
||||||
|
|
@ -429,7 +429,7 @@ function file_field_widget_settings_form($field, $instance) {
|
||||||
/**
|
/**
|
||||||
* Implementation of hook_field_widget().
|
* Implementation of hook_field_widget().
|
||||||
*/
|
*/
|
||||||
function file_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
|
function file_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
|
||||||
$form['#attributes'] = array('enctype' => 'multipart/form-data');
|
$form['#attributes'] = array('enctype' => 'multipart/form-data');
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
|
|
@ -461,27 +461,21 @@ function file_field_widget(&$form, &$form_state, $field, $instance, $langcode, $
|
||||||
|
|
||||||
// Essentially we use the managed_file type, extended with some enhancements.
|
// Essentially we use the managed_file type, extended with some enhancements.
|
||||||
$element_info = element_info('managed_file');
|
$element_info = element_info('managed_file');
|
||||||
$element = array(
|
$element += array(
|
||||||
'#type' => 'managed_file',
|
'#type' => 'managed_file',
|
||||||
'#default_value' => isset($items[$delta]) ? $items[$delta] : $defaults,
|
'#default_value' => isset($items[$delta]) ? $items[$delta] : $defaults,
|
||||||
'#required' => $instance['required'],
|
|
||||||
'#upload_location' => file_field_widget_uri($field, $instance),
|
'#upload_location' => file_field_widget_uri($field, $instance),
|
||||||
'#upload_validators' => file_field_widget_upload_validators($field, $instance),
|
'#upload_validators' => file_field_widget_upload_validators($field, $instance),
|
||||||
'#value_callback' => 'file_field_widget_value',
|
'#value_callback' => 'file_field_widget_value',
|
||||||
'#process' => array_merge($element_info['#process'], array('file_field_widget_process')),
|
'#process' => array_merge($element_info['#process'], array('file_field_widget_process')),
|
||||||
// Allows this field to return an array instead of a single value.
|
// Allows this field to return an array instead of a single value.
|
||||||
'#extended' => TRUE,
|
'#extended' => TRUE,
|
||||||
// Add extra Field properties.
|
|
||||||
'#field_name' => $field['field_name'],
|
|
||||||
'#bundle' => $instance['bundle'],
|
|
||||||
'#object_type' => $instance['object_type'],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($field['cardinality'] == 1) {
|
if ($field['cardinality'] == 1) {
|
||||||
// If there's only one field, return it as delta 0.
|
// If there's only one field, return it as delta 0.
|
||||||
$element['#title'] = $instance['label'];
|
|
||||||
if (empty($element['#default_value']['fid'])) {
|
if (empty($element['#default_value']['fid'])) {
|
||||||
$element['#description'] = theme('file_upload_help', array('description' => $instance['description'], 'upload_validators' => $element['#upload_validators']));
|
$element['#description'] = theme('file_upload_help', array('description' => $element['#description'], 'upload_validators' => $element['#upload_validators']));
|
||||||
}
|
}
|
||||||
$elements = array($element);
|
$elements = array($element);
|
||||||
}
|
}
|
||||||
|
|
@ -499,7 +493,7 @@ function file_field_widget(&$form, &$form_state, $field, $instance, $langcode, $
|
||||||
$elements[$delta] = $element;
|
$elements[$delta] = $element;
|
||||||
$elements[$delta]['#default_value'] = $defaults;
|
$elements[$delta]['#default_value'] = $defaults;
|
||||||
$elements[$delta]['#weight'] = $delta;
|
$elements[$delta]['#weight'] = $delta;
|
||||||
$elements[$delta]['#required'] = ($instance['required'] && $delta == 0);
|
$elements[$delta]['#required'] = ($element['#required'] && $delta == 0);
|
||||||
}
|
}
|
||||||
// The group of elements all-together need some extra functionality
|
// The group of elements all-together need some extra functionality
|
||||||
// after building up the full list (like draggable table rows).
|
// after building up the full list (like draggable table rows).
|
||||||
|
|
@ -508,8 +502,11 @@ function file_field_widget(&$form, &$form_state, $field, $instance, $langcode, $
|
||||||
$elements['#theme_wrappers'] = array('fieldset');
|
$elements['#theme_wrappers'] = array('fieldset');
|
||||||
$elements['#attributes']['class'] = array('file-widget');
|
$elements['#attributes']['class'] = array('file-widget');
|
||||||
$elements['#process'] = array('file_field_widget_process_multiple');
|
$elements['#process'] = array('file_field_widget_process_multiple');
|
||||||
$elements['#title'] = $instance['label'];
|
$elements['#title'] = $element['#title'];
|
||||||
$elements['#description'] = $instance['description'];
|
$elements['#description'] = $element['#description'];
|
||||||
|
$elements['#object_type'] = $element['#object_type'];
|
||||||
|
$elements['#bundle'] = $element['#bundle'];
|
||||||
|
$elements['#field_name'] = $element['#field_name'];
|
||||||
|
|
||||||
// Add some properties that will eventually be added to the file upload
|
// Add some properties that will eventually be added to the file upload
|
||||||
// field. These are added here so that they may be referenced easily through
|
// field. These are added here so that they may be referenced easily through
|
||||||
|
|
|
||||||
|
|
@ -305,8 +305,8 @@ function image_field_widget_settings_form($field, $instance) {
|
||||||
/**
|
/**
|
||||||
* Implementation of hook_field_widget().
|
* Implementation of hook_field_widget().
|
||||||
*/
|
*/
|
||||||
function image_field_widget(&$form, &$form_state, $field, $instance, $items, $delta = 0) {
|
function image_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
|
||||||
$elements = file_field_widget($form, $form_state, $field, $instance, $items, $delta);
|
$elements = file_field_widget($form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
|
||||||
$settings = $instance['settings'];
|
$settings = $instance['settings'];
|
||||||
|
|
||||||
foreach (element_children($elements) as $delta) {
|
foreach (element_children($elements) as $delta) {
|
||||||
|
|
|
||||||
|
|
@ -489,40 +489,12 @@ function field_test_field_widget_info() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement hook_field_widget().
|
* Implement hook_field_widget().
|
||||||
*
|
|
||||||
* Attach a single form element to the form. It will be built out and
|
|
||||||
* validated in the callback(s) listed in hook_element_info(). We build it
|
|
||||||
* out in the callbacks rather than here in hook_widget so it can be
|
|
||||||
* plugged into any module that can provide it with valid
|
|
||||||
* $field information.
|
|
||||||
*
|
|
||||||
* If there are multiple values for this field, the field module will
|
|
||||||
* call this function as many times as needed.
|
|
||||||
*
|
|
||||||
* @param $form
|
|
||||||
* the entire form array, $form['#node'] holds node information
|
|
||||||
* @param $form_state
|
|
||||||
* the form_state, $form_state['values'][$field['field_name']]
|
|
||||||
* holds the field's form values.
|
|
||||||
* @param $field
|
|
||||||
* The field structure.
|
|
||||||
* @param $instance
|
|
||||||
* the instance array
|
|
||||||
* @param $items
|
|
||||||
* array of default values for this field
|
|
||||||
* @param $delta
|
|
||||||
* the order of this item in the array of subelements (0, 1, 2, etc)
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* the form item for a single element for this field
|
|
||||||
*/
|
*/
|
||||||
function field_test_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
|
function field_test_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
|
||||||
$element = array(
|
$element = array(
|
||||||
'value' => array(
|
'value' => $element + array(
|
||||||
'#title' => $instance['label'],
|
|
||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
'#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : '',
|
'#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : '',
|
||||||
'#required' => $instance['required'],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return $element;
|
return $element;
|
||||||
|
|
|
||||||
|
|
@ -1211,8 +1211,8 @@ function taxonomy_term_title($term) {
|
||||||
/**
|
/**
|
||||||
* Implement hook_field_widget().
|
* Implement hook_field_widget().
|
||||||
*/
|
*/
|
||||||
function taxonomy_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = NULL) {
|
function taxonomy_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
|
||||||
$element = array(
|
$element += array(
|
||||||
'#type' => $instance['widget']['type'],
|
'#type' => $instance['widget']['type'],
|
||||||
'#default_value' => !empty($items) ? $items : array(),
|
'#default_value' => !empty($items) ? $items : array(),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue