FeedImporterAddForm.php in Feed Import 8
File
src/Form/FeedImporterAddForm.php
View source
<?php
namespace Drupal\feed_import\Form;
use Drupal\feed_import\Form\FeedImporterFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\feed_import_base\FeedImport;
class FeedImporterAddForm extends FeedImporterFormBase {
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['entity'] = [
'#type' => 'select',
'#options' => FeedImport::getAllEntities(),
'#default_value' => 'node',
'#title' => $this
->t('Entity name'),
'#description' => $this
->t('Entity where you want to import content. Ex: node, user, ...'),
'#maxlength' => 64,
'#required' => TRUE,
];
$form['cron_import'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Import at cron'),
'#default_value' => FALSE,
'#description' => $this
->t('Check this if you want to import feed items when cron runs.'),
];
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
drupal_set_message($this
->t('Feed Importer %name was created.', array(
'%name' => $this->entity
->label(),
)));
}
public function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
$actions['submit']['#value'] = $this
->t('Create new feed importer');
return $actions;
}
}