public function MaestroBatchFunctionTask::getTaskEditForm in Maestro 8.2
Same name and namespace in other branches
- 3.x src/Plugin/EngineTasks/MaestroBatchFunctionTask.php \Drupal\maestro\Plugin\EngineTasks\MaestroBatchFunctionTask::getTaskEditForm()
Method to allow a task to add their own fields to the task edit form.
Parameters
array $task: This is the array representation of the task from the configuration entity.
string $templateMachineName: The Maestro template machine name.
Return value
array Array Must return form declaration fields for the task editor
Overrides MaestroEngineTaskInterface::getTaskEditForm
File
- src/
Plugin/ EngineTasks/ MaestroBatchFunctionTask.php, line 143
Class
- MaestroBatchFunctionTask
- Maestro Batch Function Task Plugin.
Namespace
Drupal\maestro\Plugin\EngineTasksCode
public function getTaskEditForm(array $task, $templateMachineName) {
$form = [
'#markup' => t('Batch Function Edit'),
];
// Let modules signal the handlers they wish to share.
$handlers = \Drupal::moduleHandler()
->invokeAll('maestro_batch_handlers', []);
$handler_desc = $this
->t('The batch function name you wish to call.');
if (isset($task['handler']) && isset($handlers[$task['handler']])) {
$handler_desc = $handlers[$task['handler']];
}
$form['handler'] = [
'#type' => 'textfield',
'#title' => $this
->t('Handler'),
'#default_value' => isset($task['handler']) ? $task['handler'] : '',
'#required' => TRUE,
'#autocomplete_route_name' => 'maestro.autocomplete.batch_handlers',
'#ajax' => [
'callback' => [
$this,
'batchFunctionHandlerCallback',
],
'event' => 'autocompleteclose',
'wrapper' => 'handler-ajax-refresh-wrapper',
'progress' => [
'type' => 'throbber',
'message' => NULL,
],
],
];
$form['handler_help_text'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $handler_desc,
'#readonly' => TRUE,
'#attributes' => [
'class' => [
'handler-help-message',
],
'id' => [
'handler-ajax-refresh-wrapper',
],
],
];
return $form;
}