You are here

public static function ScssFontFamily::addMoreAjax in SCSS Compiler 1.0.x

Ajax callback for the "Add another item" button.

This returns the new element markup to replace the now obsolete element markup with the newly added element child.

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 36

Class

ScssFontFamily
A form element to represent font families.

Namespace

Drupal\compiler_scss\Element

Code

public static function addMoreAjax(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);
    return $element;
  }
}