hasFileElement example

/** * {@inheritdoc} */
  public function getCacheableArray() {
    return [
      'build_info' => $this->getBuildInfo(),
      'response' => $this->getResponse(),
      'programmed' => $this->isProgrammed(),
      'programmed_bypass_access_check' => $this->isBypassingProgrammedAccessChecks(),
      'process_input' => $this->isProcessingInput(),
      'has_file_element' => $this->hasFileElement(),
      'storage' => $this->getStorage(),
      // Use the properties directly, since self::isCached() combines them and       // cannot be relied upon.       'cache' => $this->cache,
      'no_cache' => $this->no_cache,
    ];
  }

  /** * {@inheritdoc} */
  
->shouldBeCalled();

    $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setHasFileElement($has_file_element));
  }

  /** * @covers ::hasFileElement * * @dataProvider providerSingleBooleanArgument */
  public function testHasFileElement($has_file_element) {
    $this->decoratedFormState->hasFileElement()
      ->willReturn($has_file_element)
      ->shouldBeCalled();

    $this->assertSame($has_file_element$this->formStateDecoratorBase->hasFileElement());
  }

  /** * @covers ::setLimitValidationErrors * * @dataProvider providerLimitValidationErrors */
  

  public function setHasFileElement($has_file_element = TRUE) {
    $this->decoratedFormState->setHasFileElement($has_file_element);

    return $this;
  }

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

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

    return $this;
  }

  
// If there is a file element, we need to flip a flag so later the     // form encoding can be set.     if (isset($element['#type']) && $element['#type'] == 'file') {
      $form_state->setHasFileElement();
    }

    // Final tasks for the form element after self::doBuildForm() has run for     // all other elements.     if (isset($element['#type']) && $element['#type'] == 'form') {
      // If there is a file element, we set the form encoding.       if ($form_state->hasFileElement()) {
        $element['#attributes']['enctype'] = 'multipart/form-data';
      }

      // Allow Ajax submissions to the form action to bypass verification. This       // is especially useful for multipart forms, which cannot be verified via       // a response header.       $element['#attached']['drupalSettings']['ajaxTrustedUrl'][$element['#action']] = TRUE;

      // If a form contains a single textfield, and the ENTER key is pressed       // within it, Internet Explorer submits the form with no POST data       // identifying any submit button. Other browsers submit POST data as
Home | Imprint | This part of the site doesn't use cookies.