class FormTestArgumentsObject
Same name and namespace in other branches
- 11.x core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php \Drupal\form_test\FormTestArgumentsObject
- 10 core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php \Drupal\form_test\FormTestArgumentsObject
- 8.9.x core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php \Drupal\form_test\FormTestArgumentsObject
Provides a test form object that needs arguments.
@internal
Hierarchy
- class \Drupal\Core\Form\FormBase extends \Drupal\Core\Form\FormInterface, \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses \Drupal\Core\Form\ConfigFormBaseTrait implements \Drupal\Core\Form\FormBase
- class \Drupal\form_test\FormTestArgumentsObject implements \Drupal\Core\Form\ConfigFormBase
- class \Drupal\Core\Form\ConfigFormBase uses \Drupal\Core\Form\ConfigFormBaseTrait implements \Drupal\Core\Form\FormBase
Expanded class hierarchy of FormTestArgumentsObject
1 string reference to 'FormTestArgumentsObject'
- form_test.routing.yml in core/
modules/ system/ tests/ modules/ form_test/ form_test.routing.yml - core/modules/system/tests/modules/form_test/form_test.routing.yml
File
-
core/
modules/ system/ tests/ modules/ form_test/ src/ FormTestArgumentsObject.php, line 13
Namespace
Drupal\form_testView source
class FormTestArgumentsObject extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'form_test_form_test_arguments_object';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'form_test.object',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $arg = NULL) {
$form['element'] = [
'#markup' => 'The FormTestArgumentsObject::buildForm() method was used for this form.',
];
$form['bananas'] = [
'#type' => 'textfield',
'#default_value' => $arg,
'#title' => $this->t('Bananas'),
];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
];
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$this->messenger()
->addStatus($this->t('The FormTestArgumentsObject::validateForm() method was used for this form.'));
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->messenger()
->addStatus($this->t('The FormTestArgumentsObject::submitForm() method was used for this form.'));
$this->config('form_test.object')
->set('bananas', $form_state->getValue('bananas'))
->save();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.