function workflowfield_field_widget_form in Workflow 7.2
Same name and namespace in other branches
- 7 workflow_field/workflowfield.widget.inc \workflowfield_field_widget_form()
Implements hook_field_widget_form().
param $langcode obsolete. Removed from formElement() parameter list.
This is a wrapper function for the 'workflow form' Widget. $form is modified by reference.
1 string reference to 'workflowfield_field_widget_form'
- workflowfield.module in workflow_field/
workflowfield.module - Supports workflows made up of arbitrary states.
File
- workflow_field/
workflowfield.widget.inc, line 38 - Defines a Workflow Field, Widget and Formatter for Workflow.
Code
function workflowfield_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
if (!isset($element['#entity'])) {
// We are now on the 'Manage Fields | Edit' settings page, so do nothing.
return $element;
}
elseif (!isset($element['#entity_type'])) {
// Not used: On an Entity View page, the widget is shown via
// workflowfield_field_formatter_view() and workflow_transition_form().
return $element;
}
else {
// We are on an Entity add/edit page.
if (!empty($field['settings']['widget']['hide'])) {
// We want the widget to be hidden, when states are only to be
// changed via Workflow History tab.
// This setting is needed, because D7 core does't have a <hidden> widget.
// @todo D8: remove this, since hidden widgets are available.
return $element;
}
else {
// Show the widget.
$entity_type = $element['#entity_type'];
$entity = $element['#entity'];
if ($entity_type == 'comment') {
// On a comment form, get the referenced entity.
$entity_type = 'node';
// Comments are only possible on nodes.
$entity = $form['#node'];
// Make sure no action buttons are added.
$instance['widget']['settings']['submit_function'] = array();
}
// Build a new $element.
// Do not use drupal_get_form() or you'll have a form in a form.
$element = array();
$widget = new WorkflowTransitionForm($field, $instance, $entity_type, $entity);
$element = $widget
->buildForm($element, $form_state);
return $element;
}
}
return $element;
}