I have a problem with my module that only creates a form to submit a validation. The target of this module is to set a variable that I put in a textfield. The problem is that it doesn't save the variable, it only shows the default value. (I use variable_set and variable_get)
This variable is necessary because I use this form in another module that get this variable from the database. (My variable is id_event)
This is my code of my own module:
<?php
function example_form_form1(){
$form['id_event'] = array(
'#type' => 'textfield',
'#title' => t('Id Event'),
'#required' => TRUE,
'#value' => variable_get('id_event', 7), //Here is my dude
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('enviar'),
);
return $form;
}
function example_form_submit($form, $form_state){
$id_event = $form_state['values']['id_event'];
variable_set('id_event', $id_event);//here is my dude
drupal_set_message($id_event);
}
?>
Now, this variable is necesary for other module that only get.
<?php
$file_json = $this->options['xml_file'].variable_get('id_event', 1);
//Here don't get the value that i put, only put the value for default.
?>
Thanks :D