I want to create a custom form with a few textfields and then use variable_set
to save those textfields as variables.
I am not able to save the variable with the code below.
Question: I do not see the drupal message on hitting submit and when I go to the 'variables' table, I do not see the variable 'id_event'. I have tried clearing all caches several times.
Code below is from *.module file of my custom module "mymodule"
function mymodule_menu() {
$items['example_form'] = array(
'title' => 'Progress Numbers',
'description' => 'Form to enter variables that will be shown on Progress Update Block on Front Page',
'page callback' => 'drupal_get_form',
'page arguments' => array('example_form_form1'),
'access arguments' => array('access administration menu'),
);
return $items;
}
The callback function:
function example_form_form1($form, &$form_state) {
$form['id_event'] = array(
'#type' => 'textfield',
'#title' => t('Id Event'),
'#required' => TRUE,
'#default_value' => variable_get('id_event', 7),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
Submit Function
function example_form_form1_submit(&$form, &$form_state) {
variable_set('id_event', $form_state['values']['id_event']);
drupal_set_message($id_event);
}