function public static function Element::createStandalone

8.x-3.x Element.php public static Element::createStandalone($element = [], FormStateInterface $form_state = NULL)

Creates a new standalone \Drupal\bootstrap\Utility\Element instance.

It does not reference the original element passed. If an Element instance is passed, it will clone it so it doesn't affect the original element.


array|string|\Drupal\bootstrap\Utility\Element $element: A render array element, string or Element instance.

\Drupal\Core\Form\FormStateInterface $form_state: A current FormState instance, if any.

Return value

\Drupal\bootstrap\Utility\Element The newly created element instance.


Provides helper methods for Drupal render elements.



Source src/Utility/Element.php (line 296)

public static function createStandalone($element = [], FormStateInterface $form_state = NULL) {
  // Immediately return a cloned version if element is already an Element.
  if ($element instanceof self) {
    return clone $element;
  $standalone = is_object($element) ? clone $element : $element;
  return static::create($standalone, $form_state);