You are here

public function DynamicFilterForm::ajaxAddItem in Feed Import 8

Ajax callback to add a new item

File

src/Form/DynamicFilterForm.php, line 253
Contains \Drupal\feed_import\Form\DynamicFilterForm

Class

DynamicFilterForm

Namespace

Drupal\feed_import\Form

Code

public function ajaxAddItem(array &$form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  if ($form_state
    ->get('field_added')) {
    $selector = '#' . $form['add_new_func']['#ajax']['wrapper'];
    $content = $form['fields']['container_' . $form_state
      ->get('current_item')];
    $response
      ->addCommand(new AfterCommand($selector, $content));
  }
  $status = array(
    '#type' => 'status_messages',
  );
  $response
    ->addCommand(new ReplaceCommand('#func-container', $form['func']));
  $response
    ->addCommand(new RemoveCommand('div.messages'));
  $response
    ->addCommand(new BeforeCommand('.region-highlighted', $status));
  return $response;
}