I'm writing an installation profile, and I want to display some forms on some pages. The form below intended to set a variable at submission time. It does not work in the profile, but it works on an installed site. Why? Where is mistake?

function myprofile_install_mode_form() {
  $form = array();
  $form['myprofile_install_mode'] = array(
    '#type' => 'radios',
    '#title' => st('Please select'),
    '#default_value' => 0,
    '#description' => '',
    '#options' => array(st('Option 1'), st('Option 2')),
  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => st('Continue'),
  return $form;
// Submit handler
function myprofile_install_mode_form_submit(&$form, &$form_state) {
  $value = $form_state['values']['myprofile_install_mode'];
  variable_set('myprofile_install_mode', $value);
  • 1
    Can you elaborate on "does not work". How do you display the form?
    – googletorp
    Commented Feb 14, 2012 at 20:36

1 Answer 1


variable_set() works fine in installation profiles (standard_install() uses it), it's more likely that the submit handler for your form isn't being run. I seem to remember having to explicitly set the submit handler for one of these extra installation forms:

$form['#submit'][] = 'myprofile_install_mode_form_submit';

Try adding a call to drupal_set_message() in the form submit handler to make sure your code is definitely being run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.