You are here

function button_field_field_widget_form in Button Field 7

Implements hook_field_widget_form().

File

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

Code

function button_field_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

  // If this field is to be hidden on the edit form then we have nothing to do.
  if (!empty($instance['widget']['settings']['edit_hidden'])) {
    return $element;
  }
  $entity_type = $element['#entity_type'];
  $entity_id = $entity = NULL;
  if (isset($form_state[$entity_type])) {
    $entity =& $form_state[$entity_type];
    $ids = entity_extract_ids($entity_type, $entity);
    $entity_id = $ids[0];
  }
  $id = _button_field_build_id($field, 'edit', $delta, $langcode);
  $element = _button_field_build_element($id, $field, $instance, $entity_type, $entity);
  return $element;
}