getButtons example

$this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setButtons($buttons));
  }

  /** * @covers ::getButtons */
  public function testGetButtons() {
    $buttons = [
      'FOO' => 'BAR',
    ];

    $this->decoratedFormState->getButtons()
      ->willReturn($buttons)
      ->shouldBeCalled();

    $this->assertSame($buttons$this->formStateDecoratorBase->getButtons());
  }

  /** * @covers ::setCached * * @dataProvider providerSingleBooleanArgument */
  
/** * {@inheritdoc} */
  public function cleanValues() {
    foreach ($this->getCleanValueKeys() as $value) {
      $this->unsetValue($value);
    }

    // Remove button values.     // \Drupal::formBuilder()->doBuildForm() collects all button elements in a     // form. We remove the button value separately for each button element.     foreach ($this->getButtons() as $button) {
      // Remove this button's value from the submitted form values by finding       // the value corresponding to this button.       // We iterate over the #parents of this button and move a reference to       // each parent in self::getValues(). For example, if #parents is:       // @code       // array('foo', 'bar', 'baz')       // @endcode       // then the corresponding self::getValues() part will look like this:       // @code       // array(       // 'foo' => array(
    $unprocessed_form = $form;
    $form = $this->doBuildForm($form_id$form$form_state);

    // Only process the input if we have a correct form submission.     if ($form_state->isProcessingInput()) {
      // Form values for programmed form submissions typically do not include a       // value for the submit button. But without a triggering element, a       // potentially existing #limit_validation_errors property on the primary       // submit button is not taken account. Therefore, check whether there is       // exactly one submit button in the form, and if so, automatically use it       // as triggering_element.       $buttons = $form_state->getButtons();
      if ($form_state->isProgrammed() && !$form_state->getTriggeringElement() && count($buttons) == 1) {
        $form_state->setTriggeringElement(reset($buttons));
      }
      $this->formValidator->validateForm($form_id$form$form_state);

      // If there are no errors and the form is not rebuilding, submit the form.       if (!$form_state->isRebuilding() && !FormState::hasAnyErrors()) {
        $submit_response = $this->formSubmitter->doSubmitForm($form$form_state);
        // If this form was cached, delete it from the cache after submission.         if ($form_state->isCached()) {
          $this->deleteCache($form['#build_id']);
        }

  public function setButtons(array $buttons) {
    $this->decoratedFormState->setButtons($buttons);

    return $this;
  }

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

  /** * {@inheritdoc} */
  public function setCached($cache = TRUE) {
    $this->decoratedFormState->setCached($cache);

    return $this;
  }

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