You are here

protected function YamlFormUiElementFormBase::isParentElementFlexbox in YAML Form 8

Determine if the parent element is a 'yamlform_flexbox'.

Parameters

string|null $key: The element's key. Only applicable for existing elements.

string|null $parent_key: The element's parent key. Only applicable for new elements. Parent key is set via query string parameter. (?parent={parent_key})

Return value

bool TRUE if the parent element is a 'yamlform_flexbox'.

1 call to YamlFormUiElementFormBase::isParentElementFlexbox()
YamlFormUiElementFormBase::buildForm in modules/yamlform_ui/src/Form/YamlFormUiElementFormBase.php
Form constructor.

File

modules/yamlform_ui/src/Form/YamlFormUiElementFormBase.php, line 368

Class

YamlFormUiElementFormBase
Provides a base class for form element forms.

Namespace

Drupal\yamlform_ui\Form

Code

protected function isParentElementFlexbox($key = NULL, $parent_key = NULL) {
  $elements = $this->yamlform
    ->getElementsInitializedAndFlattened();

  // Check the element #yamlform_parent_flexbox property.
  if ($key && isset($elements[$key])) {
    return $elements[$key]['#yamlform_parent_flexbox'];
  }

  // Check the parent element #type.
  if ($parent_key && isset($elements[$parent_key]) && isset($elements[$parent_key]['#type'])) {
    return $elements[$parent_key]['#type'] == 'yamlform_flexbox' ? TRUE : FALSE;
  }
  return FALSE;
}