You are here

protected function WebformUiElementFormBase::getParentKeyPrefix in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_ui/src/Form/WebformUiElementFormBase.php \Drupal\webform_ui\Form\WebformUiElementFormBase::getParentKeyPrefix()

Get the parent key prefix.

Parent key prefix only applies to elements withing a 'webform_table_row'.

Parameters

string|null $parent_key: The element's parent key.

Return value

string|null The parent key prefix or NULL is no parent key prefix is applicable.

2 calls to WebformUiElementFormBase::getParentKeyPrefix()
WebformUiElementFormBase::buildForm in modules/webform_ui/src/Form/WebformUiElementFormBase.php
Form constructor.
WebformUiElementFormBase::validateForm in modules/webform_ui/src/Form/WebformUiElementFormBase.php
Form validation handler.

File

modules/webform_ui/src/Form/WebformUiElementFormBase.php, line 584

Class

WebformUiElementFormBase
Provides a base class for webform element webforms.

Namespace

Drupal\webform_ui\Form

Code

protected function getParentKeyPrefix($parent_key) {
  if (!$this
    ->isParentKeyPrefixEnabled($parent_key)) {
    return NULL;
  }
  while ($parent_key) {
    $parent_element = $this
      ->getWebform()
      ->getElement($parent_key);
    if (strpos($parent_key, '01') !== FALSE && $parent_element['#type'] === 'webform_table_row') {
      return $parent_element['#webform_key'];
    }
    $parent_key = $parent_element['#webform_parent_key'];
  }
  return NULL;
}