Loading src/Form/BlockClassSettingsForm.php +37 −0 Original line number Diff line number Diff line Loading @@ -64,4 +64,41 @@ class BlockClassSettingsForm extends ConfigFormBase { return $form; } /** * Validate the maxlength field. */ public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); // Get the maxlength_block_class_field field. $maxlength_block_class_field = $form_state->getValue('maxlength_block_class_field'); // Verify if is a positive value. if ($maxlength_block_class_field < 1) { $form_state->setErrorByName('maxlength_block_class_field', $this->t('The maxlength should be an positive value')); } } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Get the maxlength_block_class_field field. $maxlength_block_class_field = $form_state->getValue('maxlength_block_class_field'); // Get the config object. $config = $this->config('block_class.settings'); // Set the value. $config->set('maxlength_block_class_field', $maxlength_block_class_field); // Save that. $config->save(); parent::submitForm($form, $form_state); } } Loading
src/Form/BlockClassSettingsForm.php +37 −0 Original line number Diff line number Diff line Loading @@ -64,4 +64,41 @@ class BlockClassSettingsForm extends ConfigFormBase { return $form; } /** * Validate the maxlength field. */ public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); // Get the maxlength_block_class_field field. $maxlength_block_class_field = $form_state->getValue('maxlength_block_class_field'); // Verify if is a positive value. if ($maxlength_block_class_field < 1) { $form_state->setErrorByName('maxlength_block_class_field', $this->t('The maxlength should be an positive value')); } } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Get the maxlength_block_class_field field. $maxlength_block_class_field = $form_state->getValue('maxlength_block_class_field'); // Get the config object. $config = $this->config('block_class.settings'); // Set the value. $config->set('maxlength_block_class_field', $maxlength_block_class_field); // Save that. $config->save(); parent::submitForm($form, $form_state); } }