You are here

function _button_field_widget_html 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

1 call to _button_field_widget_html()
button_field_widget in ./button_field.module
Implementation of hook_widget().

File

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

Code

function _button_field_widget_html(&$form, &$form_state, $field, $items, $delta) {
  $name = $field['field_name'] . '-' . (isset($form['nid']['#value']) ? $form['nid']['#value'] : 0);
  $class = 'button_field' . (isset($field['widget']['additional_class']) ? ' ' . $field['widget']['additional_class'] : '');
  $element['value'] = array(
    '#type' => 'button',
    '#attributes' => array(
      'class' => $class,
    ),
    '#id' => $field['field_name'] . '-' . $form['nid']['#value'],
    '#value' => isset($field['widget']['text']) ? $field['widget']['text'] : $field['widget']['label'],
    '#prefix' => '<div class="form-item">',
    '#suffix' => '<div class="description">' . (!empty($field['widget']['description']) ? $field['widget']['description'] : '') . '</div></div>',
  );

  // end $element['value']
  return $element;
}