public function SchemaMetaTagTag::getForm in Schema.org Metatag 7
Build the form for this meta tag.
Return value
array A standard FormAPI array.
Overrides DrupalTextMetaTag::getForm
File
- src/
SchemaMetatagTag.php, line 16 - Metatag integration for the Schema.org Metatag module.
Class
- SchemaMetaTagTag
- Text-based meta tag controller.
Code
public function getForm(array $options = array()) {
$options += array(
'token types' => array(),
);
$form['value'] = isset($this->info['form']) ? $this->info['form'] : array();
$form['value'] += array(
'#type' => 'textfield',
'#title' => $this->info['label'],
'#description' => !empty($this->info['description']) ? $this->info['description'] : '',
'#default_value' => isset($this->data['value']) ? $this->data['value'] : '',
'#element_validate' => array(
'token_element_validate',
),
'#token_types' => $options['token types'],
'#maxlength' => 1024,
);
// Optional handling for items that allow multiple values.
if (!empty($this->info['multiple'])) {
$form['value']['#description'] .= ' ' . 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->info['image'])) {
$form['value']['#description'] .= ' ' . t('This will be able to extract the URL from an image field.');
}
// Optional handling for languages.
if (!empty($this->info['is_language'])) {
$form['value']['#description'] .= ' ' . t('This will not be displayed if it is set to the "Language neutral" (i.e. "und").');
}
// Optional support for select_or_other.
if ($form['value']['#type'] == 'select' && !empty($this->info['select_or_other']) && module_exists('select_or_other')) {
$form['value']['#type'] = 'select_or_other';
$form['value']['#other'] = t('Other (please type a value)');
$form['value']['#multiple'] = FALSE;
$form['value']['#other_unknown_defaults'] = 'other';
$form['value']['#other_delimiter'] = FALSE;
$form['value']['#theme'] = 'select_or_other';
$form['value']['#select_type'] = 'select';
$form['value']['#element_validate'] = array(
'select_or_other_element_validate',
);
}
// Support for dependencies, using Form API's #states system.
// @see metatag.api.php.
// @see https://api.drupal.org/drupal_process_states
if (!empty($this->info['dependencies'])) {
foreach ($this->info['dependencies'] as $specs) {
$form['value']['#states']['visible'][':input[name*="[' . $specs['dependency'] . '][' . $specs['attribute'] . ']"]'] = array(
$specs['condition'] => $specs['value'],
);
}
}
return $form;
}