public function MetatagViewsEditForm::buildForm in Metatag 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
1 call to MetatagViewsEditForm::buildForm()
- MetatagViewsAddForm::buildForm in metatag_views/
src/ Form/ MetatagViewsAddForm.php - Form constructor.
1 method overrides MetatagViewsEditForm::buildForm()
- MetatagViewsAddForm::buildForm in metatag_views/
src/ Form/ MetatagViewsAddForm.php - Form constructor.
File
- metatag_views/
src/ Form/ MetatagViewsEditForm.php, line 77
Class
- MetatagViewsEditForm
- Class MetatagViewsEditForm.
Namespace
Drupal\metatag_views\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Get the parameters from request.
$view_id = $this
->getRequest()
->get('view_id');
$display_id = $this
->getRequest()
->get('display_id');
// Get meta tags from the view entity.
$metatags = [];
if ($view_id && $display_id) {
$metatags = metatag_get_view_tags($view_id, $display_id);
}
$form['metatags'] = $this->metatagManager
->form($metatags, $form, [
'view',
]);
$form['metatags']['#title'] = $this
->t('Metatags');
$form['metatags']['#type'] = 'fieldset';
// Need to create that AFTER the $form['metatags'] as the whole form is
// passed to the $metatagManager->form() which causes duplicated field.
$form['view'] = [
'#type' => 'value',
'#title' => $this
->t('View'),
'#weight' => -100,
'#default_value' => $view_id . ':' . $display_id,
'#required' => TRUE,
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Submit'),
];
return $form;
}