Showing different page layouts based on form data I'm trying to build a multi step form. Before the second step I have to process the data inserted in step one and render different layout and form fields based on the results.

I use "drupal_get_form" callback in _menu hooks to display the form, but I think I have to use a different approach, because I can't find a way to specify a template and\or HTML code this way.

What can I do? Thanks!

MENU DECLARATION:

/**
 * Implementation of hook_menu().
 */
function clientform_menu() {
    $items['clientform/step1'] = array(
        'title' =&gt; "Estimate",
        'type' =&gt; MENU_CALLBACK,
        'access arguments' =&gt; array('access content'),
        'page callback' =&gt; 'drupal_get_form',
        'page arguments'=&gt;array('clientform_step1'));

    return $items;
}

function clientform_step1($form, &amp;$form_state){
    if(isset($form_state['values'])) {
        $currstep = $form_state['step'] + 1;
    }else {
        $currstep = 0;
    }

    $form_state['step'] = $currstep;
    $allsteps = getForm();
    $currform =  $allsteps[$currstep];

    return $currform;
}

function clientform_step1_submit($form, &amp;$form_state){
    $form_state['storedvalues'][$form_state['step']] = $form_state['values'];
    if($form_state['step'] + 1 != getNumberOfSteps()) {
        $form_state['rebuild'] = TRUE;
    }else {

        //Reached end of multipage form

    }
}
You can set a "theme callback" in a menu declaration, but that would only work if you had some way to distinguish which page/step the user is on.

The only other way I can think of would be to have some if/then statements in your form that check for what step the user is on, and alter the form how you need.