You are here

function template_preprocess_paragraphs_add_dialog in Paragraphs 8

Prepares variables for modal form add widget template.

Default template: paragraphs-add-dialog.html.twig

Parameters

array $variables: An associative array containing:

  • buttons: An array of buttons to display in the modal form.

File

./paragraphs.module, line 306
Contains paragraphs.module

Code

function template_preprocess_paragraphs_add_dialog(&$variables) {

  // Define variables for the template.
  $variables += [
    'buttons' => [],
  ];
  foreach (Element::children($variables['element']) as $key) {
    if ($key == 'add_modal_form_area') {

      // $add variable for the add button.
      $variables['add'] = $variables['element'][$key];
    }
    elseif ($key == 'add_more_delta') {

      // Add the delta to the add wrapper.
      $variables['add'][$key] = $variables['element'][$key];
    }
    else {

      // Buttons for the paragraph types in the modal form.
      $variables['buttons'][$key] = $variables['element'][$key];
    }
  }
}