You are here

public function BreadcrumbList::form in Schema.org Metatag 8.2

Create a complete form element for this property type.

Parameters

array $input_values: An array of values to be passed to the form creator, including:

  • @var string 'title' The title to use for the form element.
  • @var string 'description' The description to use for the form element.
  • @var array 'value' The current value of the form element.
  • @var string 'visibility_selector' The selector to use in assessing form element visibility, usually the @type element.
  • @var array 'tree_parent' The top level to use for @type, defaults to ''.
  • @var int 'tree_depth' The depth to go in the tree hierarchy, defaults to -1.
  • @var string 'multiple' Whether multiple values should be allowed, defaults to FALSE.

Return value

array Return a form array.

Overrides ItemListElement::form

File

src/Plugin/schema_metatag/PropertyType/BreadcrumbList.php, line 26

Class

BreadcrumbList
Provides a plugin for the 'ItemListElement' Schema.org property type.

Namespace

Drupal\schema_metatag\Plugin\schema_metatag\PropertyType

Code

public function form($input_values) {
  $value = $input_values['value'];
  $form = [
    '#type' => 'select',
    '#title' => $input_values['title'],
    '#description' => $input_values['description'],
    '#default_value' => !empty($value) ? $value : '',
    '#maxlength' => 255,
    '#empty_option' => $this
      ->t('No'),
    '#empty_value' => '',
    '#options' => [
      'Yes' => $this
        ->t('Yes'),
    ],
  ];
  return $form;
}