Using variable_get() still returning a form with the default value? So, I have a form with a default value 'You have not enabled TFA' that is editable for the user. This works, and user input is recorded in the database, but when the form is returned it shows the default value again, and I think it would be better to return the form with the inputted values.

Here is my admin.inc file:

function my_module_admin_settings_form($form, $form_state, $nid = 0){
  $form = array();
  $form['subject'] = array(
    '#title' =&gt; t('Subject Line'),
    '#descirption' =&gt; t('Default email subject line.'),
    '#type' =&gt; 'textfield',
    '#size' =&gt; '50',
    '#required' =&gt; TRUE,
    '#default_value' =&gt; variable_get('subject', 'You have not enabled TFA'),
  );

...

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Save'),
  );

  return $form;
}


Here is the code for variable_get function (for reference):

function variable_get($name, $default = NULL) {
  global $conf;

  return isset($conf[$name]) ? $conf[$name] : $default;
}


Can anybody see what is going on?
If I understand your question correctly, your values are not saved.

This is because you either need to handle storing variables (using variable_set()) in your submit callback, or use system_settings_form() to do this for you.

The latter approach is generally used for administrative settings, unless you need some additional processing or storing part of the settings somewhere else.

Do note that with system_settings_form() you don't need to add the form actions - they will be added for you.

Here's an example:

function my_module_admin_settings_form($form, $form_state, $nid = 0){
  $form = array();
  $form['subject'] = array(
    '#title' =&gt; t('Subject Line'),
    '#descirption' =&gt; t('Default email subject line.'),
    '#type' =&gt; 'textfield',
    '#size' =&gt; '50',
    '#required' =&gt; TRUE,
    '#default_value' =&gt; variable_get('subject', 'You have not enabled TFA'),
  );

  // Add more fields.

  return system_settings_form($form);
}