Drupal - 在成功提交时添加表单元素

时间:2010-06-29 20:52:01

标签: drupal forms submit

在Drupal自定义模块中,我想使$ form ['link_wrapper']成功提交表单,但这不是一个非常成功的方法。任何人都可以建议更好的方法。

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

1 个答案:

答案 0 :(得分:0)

您是否尝试在验证挂钩中设置条件?

类似的东西:

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

这很粗糙。我不记得hook_validate

的args