You are here

protected function WebformTableRow::hasIncrementalChildrenElements in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElement/WebformTableRow.php \Drupal\webform\Plugin\WebformElement\WebformTableRow::hasIncrementalChildrenElements()

Determine if an element and its use incremental keys.

Parameters

string $key: An element key.

Return value

bool TRUE if an element and its use incremental keys.

1 call to WebformTableRow::hasIncrementalChildrenElements()
WebformTableRow::form in src/Plugin/WebformElement/WebformTableRow.php
Gets the actual configuration webform array to be built.

File

src/Plugin/WebformElement/WebformTableRow.php, line 346

Class

WebformTableRow
Provides a 'webform_table_row' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

protected function hasIncrementalChildrenElements($key) {

  // Return FALSE if the key is not incremental.
  if (!preg_match('/\\d+/', $key, $match)) {
    return FALSE;
  }
  $element = $this
    ->getWebform()
    ->getElement($key);
  foreach ($element['#webform_children'] as $child_key) {

    // Return FALSE if any child element key is not incremental.
    if (!$this
      ->hasIncrementalChildrenElements($child_key)) {
      return FALSE;
    }
  }
  return TRUE;
}