开发者

Drupal - add form element on successful submission

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;
}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜