You are here

public function MaestroInteractiveTask::validateTaskEditForm in Maestro 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/EngineTasks/MaestroInteractiveTask.php \Drupal\maestro\Plugin\EngineTasks\MaestroInteractiveTask::validateTaskEditForm()

This method must be called by the template builder in order to validate the form entry values before saving.

Overrides MaestroEngineTaskInterface::validateTaskEditForm

File

src/Plugin/EngineTasks/MaestroInteractiveTask.php, line 278

Class

MaestroInteractiveTask
Maestro Interactive Task Plugin.

Namespace

Drupal\maestro\Plugin\EngineTasks

Code

public function validateTaskEditForm(array &$form, FormStateInterface $form_state) {
  $handler = $form_state
    ->getValue('handler');

  /* Test if the interactive function name has comments in it's name
   * Defined inside [] so they can appear in the auto-complete result to the user.
   * Need to strip these comments out since they are not part of the real function name
   */
  if (strpos($handler, '[') > 0) {
    $string_parts = explode('[', $handler);
    $handler = $string_parts[0];
  }

  // Let's validate the handler here to ensure that it actually exists.
  if ($handler != '' && !function_exists($handler)) {
    $form_state
      ->setErrorByName('handler', $this
      ->t('This handler form function does not exist.'));
  }
}