TrumbaConfigurationForm.php in Trumba 8
File
src/Form/TrumbaConfigurationForm.php
View source
<?php
namespace Drupal\trumba\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class TrumbaConfigurationForm extends ConfigFormBase {
protected function getEditableConfigNames() {
return [
'trumba.trumbaconfiguration',
];
}
public function getFormId() {
return 'trumba_configuration_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('trumba.trumbaconfiguration');
$form['default_web_name'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default Web Name'),
'#description' => $this
->t('This is the default unique identifier for your account on Trumba.'),
'#maxlength' => 255,
'#size' => 64,
'#default_value' => $config
->get('default_web_name'),
];
return parent::buildForm($form, $form_state);
}
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$this
->config('trumba.trumbaconfiguration')
->set('default_web_name', $form_state
->getValue('default_web_name'))
->save();
}
}