I have a problem when updating a variable with return system_settings_form($form)
- Basically, I store a variable as an integer, but when I press Save configuration, it works very well except that it saves the variable as a string, not an integer.
Here's my function:
function my_module_settings() {
$form['my_variable'] = array(
'#type' => 'select',
'#title' => t('My module variable'),
'#description' => t('Update my module variable.'),
'#options' => array(
1 => t('Set it to 1'),
2 => t('Set it to 2'),
3 => t('Set it to 3'),
),
'#default_value' => variable_get('my_variable', 3)
);
return system_settings_form($form);
}
So, if I select "Set it to 2" in the select list and hit save, I'll be getting number 2 surrounded by quotes ("2"). I've confirmed with PHP gettype that there's indeed a change of data type.
I wonder if it's related to the select list or something foolish I'm doing? I've tried using a checkbox instead and data type is correctly updated as an integer.
I've been scratching my head without finding a correct solution. Any idea what's going on?