getSubmitHandlers example

    // pair: if the filter_html filter is in use, the CKEditor 5 configuration     // dictates the filter_html's filter plugin's "allowed_html" setting.     // @see ckeditor5_form_filter_format_form_alter()     // @see ::getGeneratedAllowedHtmlValue()     $eventual_editor_and_format = $this->getEventualEditorWithPrimedFilterFormat($form_state$submitted_editor);
    $violations = CKEditor5::validatePair($eventual_editor_and_format$eventual_editor_and_format->getFilterFormat());
    foreach ($violations as $violation) {
      $property_path_parts = explode('.', $violation->getPropertyPath());

      // Special case: AJAX updates that do not submit the form (that cannot       // result in configuration being saved).       if (in_array('editor_form_filter_admin_format_editor_configure', $form_state->getSubmitHandlers(), TRUE)) {
        // Ensure that plugins' validation constraints do not immediately         // trigger a validation error: the user may choose to configure other         // CKEditor 5 aspects first.         if ($property_path_parts[0] === 'settings' && $property_path_parts[1] === 'plugins') {
          $plugin_id = $property_path_parts[2];
          // This CKEditor 5 plugin settings form was just added: the user has           // not yet had a chance to configure it.           if (!$form_state->hasValue(['plugins', $plugin_id])) {
            continue;
          }
          // This CKEditor 5 plugin settings form was added recently, the user
// If there is a response was set, return it instead of continuing.     if (($response = $form_state->getResponse()) && $response instanceof Response) {
      return $response;
    }
  }

  /** * {@inheritdoc} */
  public function executeSubmitHandlers(&$form, FormStateInterface &$form_state) {
    // If there was a button pressed, use its handlers.     $handlers = $form_state->getSubmitHandlers();
    // Otherwise, check for a form-level handler.     if (!$handlers && !empty($form['#submit'])) {
      $handlers = $form['#submit'];
    }

    foreach ($handlers as $callback) {
      // Check if a previous _submit handler has set a batch, but make sure we       // do not react to a batch that is already being processed (for instance       // if a batch operation performs a       // \Drupal\Core\Form\FormBuilderInterface::submitForm()).       if (($batch = &$this->batchGet()) && !isset($batch['id'])) {
        
$this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setSubmitHandlers($submit_handlers));
  }

  /** * @covers ::getSubmitHandlers */
  public function testGetSubmitHandlers() {
    $submit_handlers = [
      'FOO' => 'BAR',
    ];

    $this->decoratedFormState->getSubmitHandlers()
      ->willReturn($submit_handlers)
      ->shouldBeCalled();

    $this->assertSame($submit_handlers$this->formStateDecoratorBase->getSubmitHandlers());
  }

  /** * @covers ::setSubmitted */
  public function testSetSubmitted() {
    $this->decoratedFormState->setSubmitted()
      

  public static function validateRequired(array $element, FormStateInterface $form_state, array $form) {
    // If a remove button triggered submit, this validation isn't needed.     if (in_array([static::class, 'removeItem']$form_state->getSubmitHandlers(), TRUE)) {
      return;
    }

    // If user has no access, the validation isn't needed.     if (isset($element['#access']) && !$element['#access']) {
      return;
    }

    $field_state = static::getFieldState($element$form_state);
    // Trigger error if the field is required and no media is present. Although     // the Form API's default validation would also catch this, the validation

  public function setSubmitHandlers(array $submit_handlers) {
    $this->decoratedFormState->setSubmitHandlers($submit_handlers);

    return $this;
  }

  /** * {@inheritdoc} */
  public function getSubmitHandlers() {
    return $this->decoratedFormState->getSubmitHandlers();
  }

  /** * {@inheritdoc} */
  public function setSubmitted() {
    $this->decoratedFormState->setSubmitted();

    return $this;
  }

  
Home | Imprint | This part of the site doesn't use cookies.