views:

13

answers:

1

In a Drupal custom module, I want to make $form['link_wrapper'] conditional on a successful submission of the form but this is not a very successful way of doing this. Can anyone suggest better approach.

function my_function_my_form($form_state){

    //echo "-" . $form_state['post']['op'] ."-";
    //die();

    global $base_root;  
    $form = array();

        $form ['query_type'] =array (
        '#type' => 'radios',
        '#title' => t('Select from available Queries'),
        '#options' => array(
            "e_commerce_orders" => t("Query1"), 
            "new_orders" => t("Query2"), 
            "cancelled_orders" => t("Query3")),
        '#required' => TRUE, 
        );


    // only show link when submitted    
    if($form_state['post']['op'] == 'Submit')
    {   
        $form['link_wrapper'] = array(        
                '#prefix' => '<div>',
                 '#value' => l("Click to View file"),             
                '#suffix' => '</div><br><br>',
            );
    }

    // add submit button
    $form['submit'] = array(
        '#type' => 'submit', 
        '#value' => t('Submit'));

    return $form;
}
A: 

Have you tried setting your condition in the validate hook?

Something like:

function my_function_my_form_validate($form_state){
//some condition is true
$form_state['something'] = TRUE;
}

http://api.drupal.org/api/function/hook_validate/6

This is rough. I can't remember the args for hook_validate

Rimian

related questions