public function TokenFieldForm::buildForm in Display Suite 8.2
Same name and namespace in other branches
- 8.4 src/Form/TokenFieldForm.php \Drupal\ds\Form\TokenFieldForm::buildForm()
- 8.3 src/Form/TokenFieldForm.php \Drupal\ds\Form\TokenFieldForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FieldFormBase::buildForm
File
- src/
Form/ TokenFieldForm.php, line 27
Class
- TokenFieldForm
- Configures token fields.
Namespace
Drupal\ds\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $field_key = '') {
$form = parent::buildForm($form, $form_state, $field_key);
$field = $this->field;
$form['content'] = array(
'#type' => 'text_format',
'#title' => $this
->t('Field content'),
'#default_value' => isset($field['properties']['content']['value']) ? $field['properties']['content']['value'] : '',
'#format' => isset($field['properties']['content']['format']) ? $field['properties']['content']['format'] : 'plain_text',
'#base_type' => 'textarea',
'#required' => TRUE,
);
// Token support.
if (\Drupal::moduleHandler()
->moduleExists('token')) {
$form['tokens'] = array(
'#title' => $this
->t('Tokens'),
'#type' => 'container',
'#states' => array(
'invisible' => array(
'input[name="use_token"]' => array(
'checked' => FALSE,
),
),
),
);
$form['tokens']['help'] = array(
'#theme' => 'token_tree_link',
'#token_types' => 'all',
'#global_types' => FALSE,
'#dialog' => TRUE,
);
}
return $form;
}