setSubmitHandlers example

$this->assertSame($storage$this->formStateDecoratorBase->getStorage());
  }

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

    $this->decoratedFormState->setSubmitHandlers($submit_handlers)
      ->shouldBeCalled();

    $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setSubmitHandlers($submit_handlers));
  }

  /** * @covers ::getSubmitHandlers */
  public function testGetSubmitHandlers() {
    $submit_handlers = [
      'FOO' => 'BAR',
    ];
->simple_string_submit(Argument::type('array'), Argument::type(FormStateInterface::class))
      ->shouldBeCalledOnce();

    $form = [];
    $form_state = new FormState();
    $form_submitter->executeSubmitHandlers($form$form_state);

    $form['#submit'][] = [$mock->reveal(), 'hash_submit'];
    $form_submitter->executeSubmitHandlers($form$form_state);

    // $form_state submit handlers will supersede $form handlers.     $form_state->setSubmitHandlers([[$mock->reveal(), 'submit_handler']]);
    $form_submitter->executeSubmitHandlers($form$form_state);

    // Methods directly on the form object can be specified as a string.     $form_state = (new FormState())
      ->setFormObject($mock->reveal())
      ->setSubmitHandlers(['::simple_string_submit']);
    $form_submitter->executeSubmitHandlers($form$form_state);
  }

  /** * @return \Drupal\Core\Form\FormSubmitterInterface */
/** * {@inheritdoc} */
  public function DgetStorage() {
    return $this->decoratedFormState->getStorage();
  }

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

    return $this;
  }

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

  
$form_state->setTriggeringElement($buttons[0]);
      }

      $triggering_element = $form_state->getTriggeringElement();
      // If the triggering element specifies "button-level" validation and       // submit handlers to run instead of the default form-level ones, then add       // those to the form state.       if (isset($triggering_element['#validate'])) {
        $form_state->setValidateHandlers($triggering_element['#validate']);
      }
      if (isset($triggering_element['#submit'])) {
        $form_state->setSubmitHandlers($triggering_element['#submit']);
      }

      // If the triggering element executes submit handlers, then set the form       // state key that's needed for those handlers to run.       if (!empty($triggering_element['#executes_submit_callback'])) {
        $form_state->setSubmitted();
      }

      // Special processing if the triggering element is a button.       if (!empty($triggering_element['#is_button'])) {
        // Because there are several ways in which the triggering element could
Home | Imprint | This part of the site doesn't use cookies.