public function FeedForm::form in Feeds 8.3
Gets the actual form array to be built.
Overrides ContentEntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
FeedForm.php, line 47
Class
- FeedForm
- Form controller for the feed edit forms.
Namespace
Drupal\feedsCode
public function form(array $form, FormStateInterface $form_state) {
$feed = $this->entity;
$feed_type = $feed
->getType();
$form['advanced'] = [
'#type' => 'vertical_tabs',
'#attributes' => [
'class' => [
'entity-meta',
],
],
'#weight' => 99,
];
$form = parent::form($form, $form_state);
$form['plugin']['#tree'] = TRUE;
foreach ($feed_type
->getPlugins() as $type => $plugin) {
if ($this
->pluginHasForm($plugin, 'feed')) {
$feed_form = $this->formFactory
->createInstance($plugin, 'feed');
$plugin_state = (new FormState())
->setValues($form_state
->getValue([
'plugin',
$type,
], []));
$form['plugin'][$type] = $feed_form
->buildConfigurationForm([], $plugin_state, $feed);
$form['plugin'][$type]['#tree'] = TRUE;
$form_state
->setValue([
'plugin',
$type,
], $plugin_state
->getValues());
}
}
$form['author'] = [
'#type' => 'details',
'#title' => $this
->t('Authoring information'),
'#group' => 'advanced',
'#attributes' => [
'class' => [
'feeds-feed-form-author',
],
],
'#weight' => 90,
'#optional' => TRUE,
];
if (isset($form['uid'])) {
$form['uid']['#group'] = 'author';
}
if (isset($form['created'])) {
$form['created']['#group'] = 'author';
}
// Feed options for administrators.
$form['options'] = [
'#type' => 'details',
'#access' => $this
->currentUser()
->hasPermission('administer feeds'),
'#title' => $this
->t('Import options'),
'#collapsed' => TRUE,
'#group' => 'advanced',
];
$form['options']['status'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Active'),
'#default_value' => $feed
->isActive(),
'#description' => $this
->t('Uncheck the above checkbox to disable periodic import for this feed.'),
];
return $form;
}