You are here

public function MaestroTaskTrait::getBaseEditForm in Maestro 3.x

Same name and namespace in other branches
  1. 8.2 src/MaestroTaskTrait.php \Drupal\maestro\MaestroTaskTrait::getBaseEditForm()

Retrieve the core Maestro form edit elements that all tasks MUST adhere to.

Parameters

array $task: The loaded task from the template.

string $templateMachineName: The Maestro template machine name.

File

src/MaestroTaskTrait.php, line 69

Class

MaestroTaskTrait
MaestroTaskTrait.

Namespace

Drupal\maestro

Code

public function getBaseEditForm(array $task, $templateMachineName) {
  $form['template_machine_name'] = [
    '#type' => 'hidden',
    '#title' => $this
      ->t('machine name of the template.'),
    '#default_value' => $templateMachineName,
    '#required' => TRUE,
  ];
  $form['task_id'] = [
    '#type' => 'hidden',
    '#title' => $this
      ->t('the ID in the template of the task being edited.'),
    '#default_value' => $task['id'],
    '#required' => TRUE,
  ];
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('The label of the task.'),
    '#default_value' => $task['label'],
    '#required' => TRUE,
  ];
  $form['participate_in_workflow_status_stage'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Participate in Setting the Workflow Stage and Status Message?'),
    '#default_value' => isset($task['participate_in_workflow_status_stage']) ? $task['participate_in_workflow_status_stage'] : 0,
  ];
  $form['status_and_stage_fieldset'] = [
    '#type' => 'details',
    '#open' => TRUE,
    '#description' => $this
      ->t('The Maestro task console has the ability to display a progression stage/status bar to the end user. Set the status stage number and message below.'),
    '#title' => $this
      ->t('Stage and Status Message Settings'),
    '#states' => [
      'visible' => [
        ':input[name="participate_in_workflow_status_stage"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['status_and_stage_fieldset']['workflow_status_stage_number'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('The workflow stage number you wish to relate the Stage Status Message to.'),
    '#description' => $this
      ->t('When set to 0, the status message will NOT be set in the workflow.'),
    '#default_value' => isset($task['workflow_status_stage_number']) ? $task['workflow_status_stage_number'] : '0',
    '#required' => FALSE,
    '#states' => [
      'visible' => [
        ':input[name="participate_in_workflow_status_stage"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['status_and_stage_fieldset']['workflow_status_stage_message'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Stage Status message.'),
    '#default_value' => isset($task['workflow_status_stage_message']) ? $task['workflow_status_stage_message'] : '',
    '#required' => FALSE,
    '#states' => [
      'visible' => [
        ':input[name="participate_in_workflow_status_stage"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  return $form;
}