public function MaestroInteractiveTask::interactiveHandlerCallback in Maestro 3.x
Same name and namespace in other branches
- 8.2 src/Plugin/EngineTasks/MaestroInteractiveTask.php \Drupal\maestro\Plugin\EngineTasks\MaestroInteractiveTask::interactiveHandlerCallback()
Implements callback for Ajax event on objective selection.
Parameters
array $form: From render array.
\Drupal\Core\Form\FormStateInterface $form_state: Current state of form.
Return value
array Objective selection section of the form.
File
- src/
Plugin/ EngineTasks/ MaestroInteractiveTask.php, line 245
Class
- MaestroInteractiveTask
- Maestro Interactive Task Plugin.
Namespace
Drupal\maestro\Plugin\EngineTasksCode
public function interactiveHandlerCallback(array &$form, FormStateInterface $form_state) {
$selected_handler = $new_objective_id = $form_state
->getValue('handler');
// Let modules signal the handlers they wish to share.
$handlers = \Drupal::moduleHandler()
->invokeAll('maestro_interactive_handlers', []);
if ($selected_handler != '' && !function_exists($selected_handler)) {
$handler_desc = \Drupal::translation()
->translate('This handler form function does not exist.');
}
elseif (isset($handlers[$selected_handler])) {
$handler_desc = $handlers[$selected_handler];
}
else {
$handler_desc = \Drupal::translation()
->translate('The function that contains the form definition for this instance of the interactive task.');
}
$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['handler_help_text'];
}