You are here

FormHelper.php in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.8

File

src/Form/FormHelper.php
View source
<?php

namespace Drupal\varbase\Form;

use Drupal\Core\Render\ElementInfoManagerInterface;

/**
 * Form helper.
 */
class FormHelper {

  /**
   * The element info plugin manager.
   *
   * @var \Drupal\Core\Render\ElementInfoManagerInterface
   */
  protected $elementInfo;

  /**
   * FormHelper constructor.
   *
   * @param \Drupal\Core\Render\ElementInfoManagerInterface $element_info
   *   Element info plugin manager.
   */
  public function __construct(ElementInfoManagerInterface $element_info) {
    $this->elementInfo = $element_info;
  }

  /**
   * Applies standard process for elements in the form.
   *
   * @param array $element
   *   Form element.
   */
  public function applyStandardProcessing(array &$element) {
    if (empty($element['#process'])) {
      $info = $this->elementInfo
        ->getInfo($element['#type']);
      if (isset($info['#process'])) {
        $element['#process'] = $info['#process'];
      }
    }
  }

}

Classes

Namesort descending Description
FormHelper Form helper.