public function ContentHubFilterForm::form in Acquia Content Hub 8
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- acquia_contenthub_subscriber/
src/ Form/ ContentHubFilterForm.php, line 45
Class
- ContentHubFilterForm
- Prepares the form for input Content Hub Filters.
Namespace
Drupal\acquia_contenthub_subscriber\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\acquia_contenthub_subscriber\Entity\ContentHubFilter $contenthub_filter */
$contenthub_filter = $this->entity;
// Change page title for the edit operation.
if ($this->operation == 'edit') {
$form['#title'] = $this
->t('Edit Content Hub Filter: @name', [
'@name' => $contenthub_filter->name,
]);
}
$form['name'] = [
'#type' => 'textfield',
'#title' => $this
->t('Name'),
'#maxlength' => 255,
'#default_value' => $contenthub_filter
->label(),
'#description' => $this
->t('Content Hub Filter Name.'),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
'#default_value' => $contenthub_filter
->id(),
'#machine_name' => [
'exists' => [
$this,
'exist',
],
'source' => [
'name',
],
],
'#disabled' => !$contenthub_filter
->isNew(),
];
// The Publish Setting.
$form['publish_setting'] = [
'#type' => 'select',
'#title' => $this
->t('Publish Setting'),
'#options' => [
'none' => 'None',
'import' => 'Always Import',
'publish' => 'Always Publish',
],
'#default_value' => isset($contenthub_filter->publish_setting) ? $contenthub_filter->publish_setting : 'none',
'#maxlength' => 255,
'#description' => $this
->t('Sets the Publish setting for this filter.'),
'#required' => TRUE,
];
// The Search Term.
$form['search_term'] = [
'#type' => 'textfield',
'#title' => $this
->t('Search Term'),
'#maxlength' => 255,
'#default_value' => $contenthub_filter->search_term,
'#description' => $this
->t('The search term.'),
];
// The From Date.
$form['from_date'] = [
'#type' => 'date',
'#title' => $this
->t('Date From'),
'#default_value' => $contenthub_filter->from_date,
'#date_date_format' => 'm-d-Y',
'#description' => $this
->t('Date starting from'),
];
// The To Date.
$form['to_date'] = [
'#type' => 'date',
'#title' => $this
->t('Date To'),
'#date_date_format' => 'm-d-Y',
'#default_value' => $contenthub_filter->to_date,
'#description' => $this
->t('Date until'),
];
// The Source.
$form['source'] = [
'#type' => 'textfield',
'#title' => $this
->t('Sources'),
'#maxlength' => 255,
'#default_value' => $contenthub_filter->source,
'#description' => $this
->t('Source origin site UUIDs, delimited by comma ","'),
];
// The Tags.
$form['tags'] = [
'#type' => 'textfield',
'#title' => $this
->t('Tags'),
'#maxlength' => 255,
'#default_value' => $contenthub_filter->tags,
'#description' => $this
->t('Tag UUIDs, delimited by comma ","'),
];
// The Entity types.
$form['entity_types'] = [
'#type' => 'textarea',
'#title' => $this
->t('Entity Types'),
'#rows' => 4,
'#default_value' => implode("\n", $contenthub_filter
->getEntityTypes()),
'#description' => $this
->t('Entity types (one entity type id per line)'),
];
// The Bundles.
$form['bundles'] = [
'#type' => 'textarea',
'#title' => $this
->t('Bundles'),
'#rows' => 4,
'#default_value' => implode("\n", $contenthub_filter
->getBundles()),
'#description' => $this
->t('Bundles (one bundle id per line)'),
];
return $form;
}