You are here

public function ImportForm::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/ImportForm.php, line 85
Contains \Drupal\feed_import\Form\ImportForm

Class

ImportForm

Namespace

Drupal\feed_import\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $options = array(
    'name' => $form_state
      ->getValue('name'),
    'machine_name' => $form_state
      ->getValue('machine_name'),
  );
  if ($code = $this
    ->importFromJson($form_state
    ->getValue('code'), $options)) {
    drupal_set_message(t('Feed imported'));
    $form_state
      ->setRedirect('feed_import.admin_edit', [
      'fid' => $code->machine_name,
    ]);
  }
  else {
    drupal_set_message(t('Feed cannot be imported!'), 'error');
    $form_state
      ->setRedirect('feed_import.admin');
  }
}