function TreeConfigTargetForm::buildForm
Same name and namespace in other branches
- 10 core/modules/system/tests/modules/form_test/src/Form/TreeConfigTargetForm.php \Drupal\form_test\Form\TreeConfigTargetForm::buildForm()
Overrides ConfigFormBase::buildForm
1 call to TreeConfigTargetForm::buildForm()
- NestedConfigTargetForm::buildForm in core/
modules/ system/ tests/ modules/ form_test/ src/ Form/ NestedConfigTargetForm.php - Form constructor.
1 method overrides TreeConfigTargetForm::buildForm()
- NestedConfigTargetForm::buildForm in core/
modules/ system/ tests/ modules/ form_test/ src/ Form/ NestedConfigTargetForm.php - Form constructor.
File
-
core/
modules/ system/ tests/ modules/ form_test/ src/ Form/ TreeConfigTargetForm.php, line 27
Class
Namespace
Drupal\form_test\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['vegetables'] = [
'#type' => 'details',
'#open' => TRUE,
'#tree' => TRUE,
'#input' => TRUE,
'#title' => t('Vegetable preferences'),
];
$form['vegetables']['favorite'] = [
'#type' => 'textfield',
'#title' => t('Favorite'),
'#default_value' => 'Potato',
'#config_target' => 'form_test.object:favorite_vegetable',
];
$form['vegetables']['nemesis'] = [
'#type' => 'textfield',
'#title' => t('Nemesis'),
'#config_target' => 'form_test.object:nemesis_vegetable',
];
// Since form_test.object contains translatable values, it must specify a
// language.
$form['langcode'] = [
'#type' => 'value',
'#value' => 'en',
'#config_target' => 'form_test.object:langcode',
];
$form['test1'] = [
'#type' => 'select',
'#title' => $this->t('Test 1'),
'#options' => [
'option1' => $this->t('Option 1'),
'option2' => $this->t('Option 2'),
],
'#ajax' => [
'callback' => '::updateOptions',
'wrapper' => 'edit-test1-wrapper',
],
'#prefix' => '<div id="edit-test1-wrapper">',
'#suffix' => '</div>',
];
return parent::buildForm($form, $form_state);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.