public function WorkflowTransitionForm::getFormId in Workflow 8
Returns a unique string identifying the form.
The returned ID should be a unique string that can be a valid PHP function name, since it's used in hook implementation names such as hook_form_FORM_ID_alter().
Return value
string The unique string identifying the form.
Overrides EntityForm::getFormId
File
- src/
Form/ WorkflowTransitionForm.php, line 23
Class
- WorkflowTransitionForm
- Provides a Transition Form to be used in the Workflow Widget.
Namespace
Drupal\workflow\FormCode
public function getFormId() {
// We need a proprietary Form ID, to identify the unique forms
// when multiple fields or entities are shown on 1 page.
// Test this f.i. by checking the'scheduled' box. It will not unfold.
// $form_id = parent::getFormId();
/** @var \Drupal\workflow\Entity\WorkflowTransitionInterface $transition */
$transition = $this->entity;
$field_name = $transition
->getFieldName();
// Entity may be empty on VBO bulk form.
// $entity = $transition->getTargetEntity();
// Compose Form Id from string + Entity Id + Field name.
// Field ID contains entity_type, bundle, field_name.
// The Form Id is unique, to allow for multiple forms per page.
// $workflow_type_id = $transition->getWorkflowId();
// Field name contains implicit entity_type & bundle (since 1 field per entity)
// $entity_type = $transition->getTargetEntityTypeId();
// $entity_id = $transition->getTargetEntityId();;
$suffix = 'form';
// Emulate nodeForm convention.
if ($transition
->id()) {
$suffix = 'edit_form';
}
$form_id = implode('_', [
'workflow_transition',
$transition
->getTargetEntityTypeId(),
$transition
->getTargetEntityId(),
$field_name,
$suffix,
]);
$form_id = Html::getUniqueId($form_id);
return $form_id;
}