You are here

public function WorkflowDefaultWidget::formElement in Workflow 7.2

Same name and namespace in other branches
  1. 7 includes/Field/WorkflowDefaultWidget.php \WorkflowDefaultWidget::formElement()

Implements hook_field_widget_form --> WidgetInterface::formElement().

Be careful: Widget may be shown in very different places. Test carefully!!

  • On a entity add/edit page
  • On a entity preview page
  • On a entity view page
  • On a entity 'workflow history' tab
  • On a comment display, in the comment history
  • On a comment form, below the comment history

@todo D8: change "array $items" to "FieldInterface $items"

File

includes/Field/WorkflowDefaultWidget.php, line 59
Contains workflow\includes\Field\WorkflowDefaultWidget.

Class

WorkflowDefaultWidget
Plugin implementation of the 'workflow_default' widget.

Code

public function formElement(array $items, $delta, array $element, array &$form, array &$form_state) {
  $field = $this->field;
  $instance = $this->instance;
  $entity = $this->entity;
  $entity_type = $this->entity_type;

  // Add the element. Do not use drupal_get_form, or you will have a form in a form.
  workflow_transition_form($form, $form_state, $field, $instance, $entity_type, $entity);
}