You are here

public function DynamicFilterForm::submitForm in Feed Import 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

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

Class

DynamicFilterForm

Namespace

Drupal\feed_import\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $v = $form_state
    ->getValues();
  if (!$this->feed) {
    return;
  }
  $funcs = array();
  for ($i = 0; $i <= $form_state
    ->get('current_item'); $i++) {
    if (empty($v['fields']['container_' . $i]['name'])) {
      continue;
    }
    $f = $v['fields']['container_' . $i];
    unset($f['remove_container_' . $i]);
    $f = array_map('trim', $f);
    if ($f['name'] && $f['body']) {
      $funcs[] = $f;
    }
  }
  $this->feed->settings['functions'] = $funcs;
  if (FeedImport::saveFeed($this->feed)) {
    drupal_set_message(t('Feed saved'));
  }
}