You are here

public static function InsertViewDialog::getArguments in Advanced Insert View 2.0.x

Same name and namespace in other branches
  1. 8 src/Form/InsertViewDialog.php \Drupal\insert_view_adv\Form\InsertViewDialog::getArguments()

Ajax callback to get the view arguments.

Parameters

array $form: Form elements.

\Drupal\Core\Form\FormStateInterface $form_state: Form state object.

Return value

array Form element for arguments of the view.

File

src/Form/InsertViewDialog.php, line 112

Class

InsertViewDialog
Class InsertViewDialog.

Namespace

Drupal\insert_view_adv\Form

Code

public static function getArguments(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $arguments = 0;
  $num_args = $form_state
    ->get('num_args');
  if (!empty($values['inserted_view_adv'])) {
    $current_view = $values['inserted_view_adv'];
    if (!empty($form['#view_arguments'][$current_view])) {
      $arguments = count($form['#view_arguments'][$current_view]);
    }
  }
  $num_args += $arguments;
  $form_state
    ->set('num_args', $num_args);
  $form_state
    ->setRebuild(TRUE);
  return $form['arguments'];
}