public static function ScssFontFamily::addMoreSubmit in SCSS Compiler 1.0.x
Submission handler for the "Add another item" button.
This method increments the total number of children for the element.
Parameters
array $form: The form render array.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
File
- src/
Element/ ScssFontFamily.php, line 57
Class
- ScssFontFamily
- A form element to represent font families.
Namespace
Drupal\compiler_scss\ElementCode
public static function addMoreSubmit(array $form, FormStateInterface $form_state) {
// Check if a triggering element can be found.
if ($element = $form_state
->getTriggeringElement()) {
// Go one level up in the form, to the container.
$parents = array_slice($element['#array_parents'], 0, -1);
$element = NestedArray::getValue($form, $parents);
// Increment the total number of children by 1.
$count = $form_state
->get($key = "{$element['#name']}_children");
$form_state
->set($key, $count + 1);
$form_state
->setRebuild();
}
}