ConnectionSettingsForm.php in RedHen CRM 8
File
modules/redhen_connection/src/Form/ConnectionSettingsForm.php
View source
<?php
namespace Drupal\redhen_connection\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class ConnectionSettingsForm extends ConfigFormBase {
public function getFormId() {
return 'connection_settings';
}
protected function getEditableConfigNames() {
return [
'redhen_connection.settings',
];
}
public function submitForm(array &$form, FormStateInterface $form_state) {
\Drupal::service('config.factory')
->getEditable('redhen_connection.settings')
->set('auto_disable_connections', $form_state
->getValue('auto_disable_connections'))
->save();
parent::submitForm($form, $form_state);
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('redhen_connection.settings');
$form = [
'auto_disable_connections' => [
'#type' => 'checkbox',
'#title' => t('Automatically mark connections inactive when either of their endpoints are marked inactive'),
'#description' => t('When a RedHen Organization or Contact is marked inactive, all of its connections will be marked inactive.'),
'#default_value' => $config
->get('auto_disable_connections'),
],
];
return parent::buildForm($form, $form_state);
}
}