简体   繁体   中英

Drupal - hook_menu_alter for webform

I have created a webform for client where the client information gets stored and the client can login and view the form, but when the client veiw the form it displays the submission table and then the client have to click on view in operation to display the results, i wanted to implement a function so it becomes possible to redirect the clients to the actual results directly instead of the submission table while for admin the submission table should be there...i guess i need to implement hook_menu_alter() in a custom module...was wondering if someone could help me with the code for hook_menu_alter()...the url for submission table is "node/$nid/submissions" and for the results is "node/$nid/submission/$sid". Thanks

You don't need hook_menu_alter to redirect after form submission. You can simply add a #redirect to your $form at hook_form_submit()

It should be something like this:

function hook_form($form_state){
    // $form[] definition here
    $form[] = array(
        '#type'   => 'submit',
        '#value'  => 'Submit Me!',
        '#submit' => array('hook_form_submit'),
    );
}

function hook_form_submit($form,&$form_state){
    // sanitize/save your data here!
    $form_state['redirect'] = 'redirect/me/to/somewhere/else';
}

yes..both the user and the admin view the same form...n admin will be filling up the form on behalf of user and set the author as user so that user can view the filled info as we will set the user permission as "access own results". Now, the issue is when user views the webform results he gets a 'table' first which shows the 'date' and 'Operations' and in operation if user click on 'view' then the filled info is being displayed. so, i was just wondering if we can use hook_menu_alter to change that and instead of that 'table' it directly shows the filled info to the user...thanks andre..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM