public function MetatagViewsTranslationForm::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
File
- metatag_views/
src/ Form/ MetatagViewsTranslationForm.php, line 161
Class
- MetatagViewsTranslationForm
- Defines a form for translating meta tags for views.
Namespace
Drupal\metatag_views\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Get the parameters from request.
$this->viewId = $this
->getRequest()
->get('view_id');
$this->displayId = $this
->getRequest()
->get('display_id');
$langcode = $this
->getRequest()
->get('langcode');
$this->view = $this->viewsManager
->load($this->viewId);
$this->language = $this->languageManager
->getLanguage($langcode);
$this->sourceLanguage = $this->view
->language();
// Get meta tags from the view entity.
$form['#tree'] = TRUE;
$form['#attached']['library'][] = 'config_translation/drupal.config_translation.admin';
$form['#title'] = $this
->t('Edit @language translation for %view: %display metatags', [
'%view' => $this->view
->label(),
'%display' => $this->view
->getDisplay($this->displayId)['display_title'],
'@language' => $this->language
->getName(),
]);
$form['metatags'] = $this
->form($form, $this
->prepareValues());
$form['metatags']['#title'] = $this
->t('Metatags');
$form['metatags']['#type'] = 'fieldset';
$form['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Submit'),
];
return $form;
}