You are here

function button_field_widget in Button Field 6

Implementation of hook_widget().

Attach a single form element to the form.

CCK core fields only add a stub element and builds the complete item in #process so reusable elements created by hook_elements can be plugged into any module that provides valid $field information.

Custom widgets that don't care about using hook_elements can be built out completely at this time.

If there are multiple values for this field and CCK is handling multiple values, the content module will call this function as many times as needed.

Parameters

$form: the entire form array, $form['#node'] holds node information

$form_state: the form_state, $form_state['values'][$field['field_name']] holds the field's form values.

$field: the field array

$items: array of default values for this field

$delta: the order of this item in the array of subelements (0, 1, 2, etc)

Return value

the form item for a single element for this field

File

./button_field.module, line 376
Defines a field, widget and formatter for the button field type.

Code

function button_field_widget(&$form, &$form_state, $field, $items, $delta = 0) {

  // add the javascript and css files
  drupal_add_js(drupal_get_path('module', 'button_field') . '/js/button_field.js');
  drupal_add_css(drupal_get_path('module', 'button_field') . '/css/button_field.css');

  // determine the widget type
  switch ($field['widget']['type']) {
    case 'button_field_html':
      return $field['widget']['edit_hidden'] ? array() : _button_field_widget_html($form, $form_state, $field, $items, $delta);
      break;
    case 'button_field_image':
      return $field['widget']['edit_hidden'] ? array() : _button_field_widget_image($form, $form_state, $field, $items, $delta);
      break;
  }

  // end switch $field['widget']['type']
}