Skip to content
Snippets Groups Projects

Modify form for easy understanding

All threads resolved!
Files
2
@@ -31,51 +31,75 @@ class NginxProxySettingsForm extends ConfigFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('nginx_proxy_manager_connector.nginxproxysettings');
$form['api_base_url'] = [
$form['api_settings'] = [
'#type' => 'fieldset',
'#title' => $this->t('1. API Settings'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
];
$form['api_settings']['api_base_url'] = [
'#type' => 'textfield',
'#title' => $this->t('API Base URL'),
'#description' => $this->t('Enter the base url for the API calls to Nginx Proxy Manager instance'),
'#description' => $this->t('Enter the base url for the API calls to Nginx Proxy Manager instance.'),
'#maxlength' => 64,
'#size' => 64,
'#default_value' => $config->get('api_base_url'),
];
$form['default_forward_host'] = [
$form['api_settings']['email_nginx_proxy'] = [
'#type' => 'email',
'#title' => $this->t('Email'),
'#description' => $this->t('User credentials of Nginx Proxy Manager.'),
'#disabled' => FALSE,
'#default_value' => $config->get('email_nginx_proxy'),
];
$form['api_settings']['password_nginx_proxy'] = [
'#type' => 'textfield',
'#title' => $this->t('Password'),
'#description' => $this->t('User credentials of Nginx Proxy Manager.'),
'#disabled' => FALSE,
'#maxlength' => 64,
'#size' => 64,
'#default_value' => $config->get('password_nginx_proxy'),
];
$form['default_proxy_host_settings '] = [
'#type' => 'fieldset',
'#title' => $this->t('2. Default Proxy Host Settings '),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
];
$form['default_proxy_host_settings ']['default_forward_host'] = [
'#type' => 'textfield',
'#title' => $this->t('Default Forward Host'),
'#description' => $this->t('Enter the default forward host to be used for the proxy hosts created by the module (Update .env file to modify the value)'),
'#description' => $this->t('Enter the default forward host to be used for the proxy hosts created by the module.'),
'#maxlength' => 64,
'#size' => 64,
'#default_value' => $config->get('default_forward_host'),
'#disabled' => FALSE,
];
$form['default_forward_host_port'] = [
$form['default_proxy_host_settings ']['default_forward_host_port'] = [
'#type' => 'number',
'#title' => $this->t('Default Forward Host Port'),
'#description' => $this->t('Enter the default forward host port to be used.'),
'#default_value' => $config->get('default_forward_host_port'),
];
$form['letsencrypt_email'] = [
$form['certificates_settings'] = [
'#type' => 'fieldset',
'#title' => $this->t('3. Certificates'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
];
$form['certificates_settings']['letsencrypt_email'] = [
'#type' => 'email',
'#title' => $this->t('Email for generating LetsEncrypt Certificates'),
'#description' => $this->t('Enter the email used for managing LetsEncrypt Certificates.'),
'#default_value' => $config->get('letsencrypt_email'),
];
$form['email_nginx_proxy'] = [
'#type' => 'email',
'#title' => $this->t('Email'),
'#description' => $this->t('User credentials of Nginx Proxy Manager (Update .env file to modify the value)'),
'#disabled' => FALSE,
'#default_value' => $config->get('email_nginx_proxy'),
];
$form['password_nginx_proxy'] = [
'#type' => 'textfield',
'#title' => $this->t('Password'),
'#description' => $this->t('User credentials of Nginx Proxy Manager (Update .env file to modify the value)'),
'#disabled' => FALSE,
'#maxlength' => 64,
'#size' => 64,
'#default_value' => $config->get('password_nginx_proxy'),
];
return parent::buildForm($form, $form_state);
}
@@ -90,7 +114,7 @@ class NginxProxySettingsForm extends ConfigFormBase {
->set('default_forward_host', $form_state->getValue('default_forward_host'))
->set('default_forward_host_port', $form_state->getValue('default_forward_host_port'))
->set('letsencrypt_email', $form_state->getValue('letsencrypt_email'))
->set('password_nginx_proxy',$form_state->getValue('password_nginx_proxy'))
->set('password_nginx_proxy', $form_state->getValue('password_nginx_proxy'))
->set('email_nginx_proxy', $form_state->getValue('email_nginx_proxy'))
->save();
Loading