trinion_mrp-1.0.x-dev/src/Form/SettingsForm.php
src/Form/SettingsForm.php
<?php
declare(strict_types=1);
namespace Drupal\trinion_mrp\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Configure Trinion MRP settings for this site.
*/
final class SettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId(): string {
return 'trinion_mrp_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames(): array {
return ['trinion_mrp.settings'];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state): array {
$form['date_purchase_order'] = [
'#type' => 'radios',
'#title' => t('Date purchase order'),
'#options' => [
'begin_of_week' => 'Begin of work week',
],
'#default_value' => $this->config('trinion_mrp.settings')->get('date_purchase_order'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state): void {
parent::validateForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state): void {
$this->config('trinion_mrp.settings')
->set('date_purchase_order', $form_state->getValue('date_purchase_order'))
->save();
parent::submitForm($form, $form_state);
}
}
