public function SchemaSpeakableTrait::speakableForm in Schema.org Metatag 7
The form element.
1 call to SchemaSpeakableTrait::speakableForm()
- SchemaSpeakableBase::getForm in src/
SchemaSpeakableBase.php - Build the form for this meta tag.
File
- src/
SchemaSpeakableTrait.php, line 19
Class
- SchemaSpeakableTrait
- Schema.org Speakable trait.
Code
public function speakableForm($input_values) {
$input_values += $this
->schemaMetatagManager()
->defaultInputValues();
$value = $input_values['value'];
// Get the id for the nested @type element.
$selector = ':input[name="' . $input_values['visibility_selector'] . '[@type]"]';
$visibility = [
'invisible' => [
$selector => [
'value' => '',
],
],
];
$selector2 = $this
->schemaMetatagManager()
->altSelector($selector);
$visibility2 = [
'invisible' => [
$selector2 => [
'value' => '',
],
],
];
$visibility['invisible'] = [
$visibility['invisible'],
$visibility2['invisible'],
];
$form['#type'] = 'fieldset';
$form['#title'] = $input_values['title'];
$form['#description'] = $input_values['description'];
$form['#tree'] = TRUE;
$form['@type'] = [
'#type' => 'select',
'#title' => $this
->t('Type'),
'#default_value' => !empty($value['@type']) ? $value['@type'] : '',
'#empty_option' => t('- None -'),
'#empty_value' => '',
'#options' => [
'SpeakableSpecification' => $this
->t('SpeakableSpecification'),
],
'#description' => $this
->t('Please provide either xpath or cssSelector, not both.'),
];
$form['xpath'] = [
'#type' => 'textfield',
'#title' => $this
->t('xpath'),
'#default_value' => !empty($value['xpath']) ? $value['xpath'] : '',
'#description' => $this
->t('Separate xpaths by comma, as in: @example', [
'@example' => '/html/head/title, /html/head/meta[@name=\'description\']/@content',
]),
'#states' => $visibility,
];
$form['cssSelector'] = [
'#type' => 'textfield',
'#title' => $this
->t('cssSelector'),
'#default_value' => !empty($value['cssSelector']) ? $value['cssSelector'] : '',
'#description' => $this
->t('Separate selectors by comma, as in @example', [
'@example' => '#title, #summary',
]),
'#states' => $visibility,
];
return $form;
}