setProcessInput example

->shouldBeCalled();

    $this->assertSame($no_redirect$this->formStateDecoratorBase->isRedirectDisabled());
  }

  /** * @covers ::setProcessInput * * @dataProvider providerSingleBooleanArgument */
  public function testSetProcessInput($process_input) {
    $this->decoratedFormState->setProcessInput($process_input)
      ->shouldBeCalled();

    $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setProcessInput($process_input));
  }

  /** * @covers ::isProcessingInput * * @dataProvider providerSingleBooleanArgument */
  public function testIsProcessingInput($process_input) {
    
/** * {@inheritdoc} */
  public function isRedirectDisabled() {
    return $this->decoratedFormState->isRedirectDisabled();
  }

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

    return $this;
  }

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

  
public function testBuildFormWithTriggeringElement($element_value$input_value) {
    $form_id = 'test_form_id';
    $expected_form = $form_id();

    $expected_form['actions']['other_submit'] = [
      '#type' => 'submit',
      '#value' => $element_value,
    ];

    $form_arg = $this->getMockForm($form_id$expected_form, 2);
    $form_state = new FormState();
    $form_state->setProcessInput();
    $form_state->setUserInput(['form_id' => $form_id, 'op' => $input_value]);
    $this->request->setMethod('POST');
    $this->formBuilder->buildForm($form_arg$form_state);

    $this->assertEquals($expected_form['actions']['other_submit']['#value']$form_state->getTriggeringElement()['#value']);
  }

  /** * Data provider for ::testBuildFormWithTriggeringElement(). */
  public function providerTestBuildFormWithTriggeringElement() {
    
$this->container->get('entity_display.repository'),
      $this->container->get('entity_field.manager')
    );
    $form_object->setEntity($entity->reveal());

    $form = [
      '#fields' => array_keys($field_values),
      '#extra' => [],
    ];
    $form_state = new FormState();
    $form_state->setValues(['fields' => $field_values]);
    $form_state->setProcessInput();

    $form_object->buildEntity($form$form_state);
    $form_state->setSubmitted();

    // Flag one field for updating plugin settings.     $form_state->set('plugin_settings_update', 'field_plugin_settings_update');
    // During form submission, buildEntity() will be called twice. Simulate that     // here to prove copyFormValuesToEntity() is idempotent.     $form_object->buildEntity($form$form_state);
  }

}
// Store a reference to the complete form in $form_state prior to building       // the form. This allows advanced #process and #after_build callbacks to       // perform changes elsewhere in the form.       $form_state->setCompleteForm($element);

      // Set a flag if we have a correct form submission. This is always TRUE       // for programmed forms coming from self::submitForm(), or if the form_id       // coming from the POST data is set and matches the current form_id.       $input = $form_state->getUserInput();
      if ($form_state->isProgrammed() || (!empty($input) && (isset($input['form_id']) && ($input['form_id'] == $form_id)))) {
        $form_state->setProcessInput();
        if (isset($element['#token'])) {
          $input = $form_state->getUserInput();
          if (empty($input['form_token']) || !$this->csrfToken->validate($input['form_token']$element['#token'])) {
            // Set an early form error to block certain input processing since             // that opens the door for CSRF vulnerabilities.             $this->setInvalidTokenError($form_state);

            // This value is checked in self::handleInputElement().             $form_state->setInvalidToken(TRUE);

            // Ignore all submitted values.
Home | Imprint | This part of the site doesn't use cookies.