public function MetaNameBase::form in Metatag 8
Generate a form element for this meta tag.
Parameters
array $element: The existing form element to attach to.
Return value
array The completed form element.
6 methods override MetaNameBase::form()
- PinterestNohover::form in metatag_pinterest/
src/ Plugin/ metatag/ Tag/ PinterestNohover.php - Generate a form element for this meta tag.
- PinterestNopin::form in metatag_pinterest/
src/ Plugin/ metatag/ Tag/ PinterestNopin.php - Generate a form element for this meta tag.
- PinterestNosearch::form in metatag_pinterest/
src/ Plugin/ metatag/ Tag/ PinterestNosearch.php - Generate a form element for this meta tag.
- Referrer::form in src/
Plugin/ metatag/ Tag/ Referrer.php - Generate a form element for this meta tag.
- Robots::form in src/
Plugin/ metatag/ Tag/ Robots.php - Generate a form element for this meta tag.
File
- src/
Plugin/ metatag/ Tag/ MetaNameBase.php, line 263
Class
- MetaNameBase
- Each meta tag will extend this base.
Namespace
Drupal\metatag\Plugin\metatag\TagCode
public function form(array $element = []) {
$form = [
'#type' => $this
->isLong() ? 'textarea' : 'textfield',
'#title' => $this
->label(),
'#default_value' => $this
->value(),
'#maxlength' => 1024,
'#required' => isset($element['#required']) ? $element['#required'] : FALSE,
'#description' => $this
->description(),
'#element_validate' => [
[
get_class($this),
'validateTag',
],
],
];
// Optional handling for items that allow multiple values.
if (!empty($this->multiple)) {
$form['#description'] .= ' ' . $this
->t('Multiple values may be used, separated by a comma. Note: Tokens that return multiple values will be handled automatically.');
}
// Optional handling for images.
if (!empty($this
->type()) && $this
->type() === 'image') {
$form['#description'] .= ' ' . $this
->t('This will be able to extract the URL from an image field if the field is configured properly.');
}
if (!empty($this->absolute_url)) {
$form['#description'] .= ' ' . $this
->t('Any relative or protocol-relative URLs will be converted to absolute URLs.');
}
// Optional handling for secure paths.
if (!empty($this->secure)) {
$form['#description'] .= ' ' . $this
->t('Any URLs which start with "http://" will be converted to "https://".');
}
return $form;
}