protected function WebformTableRow::getNextIncrement in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformTableRow.php \Drupal\webform\Plugin\WebformElement\WebformTableRow::getNextIncrement()
Get the parent table's next row increment.
Return value
int The parent table's next row increment.
2 calls to WebformTableRow::getNextIncrement()
- WebformTableRow::form in src/
Plugin/ WebformElement/ WebformTableRow.php - Gets the actual configuration webform array to be built.
- WebformTableRow::getDefaultKey in src/
Plugin/ WebformElement/ WebformTableRow.php - Gets the element's default key.
File
- src/
Plugin/ WebformElement/ WebformTableRow.php, line 319
Class
- WebformTableRow
- Provides a 'webform_table_row' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
protected function getNextIncrement() {
$webform = $this
->getWebform();
$parent_key = \Drupal::request()->query
->get('parent');
$table_element = $webform
->getElement($parent_key);
if (!$table_element['#webform_children']) {
return 1;
}
// Get next row increment.
$indexes = [];
foreach ($table_element['#webform_children'] as $child_key) {
preg_match('/\\d+/', $child_key, $match);
$indexes[] = intval($match[0]);
}
return max($indexes) + 1;
}