backdrop-contrib / mimemail

Mime Mail provides functions for other modules to use to send HTML mail.
GNU General Public License v2.0
0 stars 5 forks source link

Use system_settings_form instead of saving form ids. #14

Closed herbdool closed 6 years ago

herbdool commented 6 years ago

The admin form https://github.com/backdrop-contrib/mimemail/blob/1.x-1.x/includes/mimemail.admin.inc saves everything to config, including the form ids which change each time. This shouldn't all be in config.

Instead you can probably use something like this:

<?php
function modulename_settings_form($form, $form_state) {
  $form['#config'] = 'modulename.settings';
  $form['my_setting'] = array(
    '#type' => 'textfield',
    '#title' => t('My setting'),
    '#default_value' => config_get('modulename.settings', 'my_setting', ''),
  );

  return system_settings_form($form);
}
?>