public function SchemaNameBase::form in Schema.org Metatag 8.2
Generate a form element for this meta tag.
This method should be overridden in classes that extend this base by creating a form element using the property type manager.
Parameters
array $element: The existing form element to attach to.
Return value
array The completed form element.
Overrides MetaNameBase::form
See also
\Drupal\schema_metatag\Plugin\schema_metatag\PropertyTypeBase::form()
File
- src/
Plugin/ metatag/ Tag/ SchemaNameBase.php, line 105
Class
- SchemaNameBase
- All Schema.org tags should extend this class.
Namespace
Drupal\schema_metatag\Plugin\metatag\TagCode
public function form(array $element = []) {
$property_type = !empty($this->pluginDefinition['property_type']) ? $this->pluginDefinition['property_type'] : 'text';
$tree_parent = !empty($this->pluginDefinition['tree_parent']) ? $this->pluginDefinition['tree_parent'] : '';
$tree_depth = !empty($this->pluginDefinition['tree_depth']) ? $this->pluginDefinition['tree_depth'] : -1;
$input_values = $this
->getInputValues();
if (!empty($tree_parent)) {
$input_values['tree_parent'] = $tree_parent;
$input_values['tree_depth'] = $tree_depth;
}
$form = $this
->propertyTypeManager()
->createInstance($property_type)
->form($input_values);
return $form;
}