I have created a Webform with some terms & condition. I have added this webform in node/upload page. When user access node/upload page webform comes as overlay on the page. When user selects all terms & condition and submits it redirects to another page which as close link. When close link is clicked webform hides.

What I want is instead clicking on close link to hide the webform. When user submits the terms & conditions the webform must be hidden. How can i achieve this. I have added screen shot of webforms. enter image description here

enter image description here

I have added this code to get the webform in node/upload page

 if (!isset($user->data['guided'])) {
  $form['#attached']['js'][] = drupal_get_path('module', 'my_module') . '/js/my_module_ajax.js';
if (!isset($user->data['guided'])) {
$form['guideline'] = array(
  '#markup' => '<p>' . t('Review and follow the guidelines outlined in the <a href="@guideline-page" class="ctools-use-modal">Submission guidelines</a> before uploading an item.', array('@guideline-page' => url('modal_forms/nojs/webform/' . 31))) . '</p>',
  '#weight' => -0.01,

2 Answers 2


I think the code mentioned in #4 should work.

  function my_module_form_id_alter(&$form, &$form_state) {
    $form["#submit"][] = "my_module_submit";
    if ( $form_state['submitted']){
      $commands[] = ctools_modal_command_dismiss();
       print ajax_render($commands);
    return $form;

 function my_module_submit($form,&$form_state) {
   $form_state['rebuild'] = TRUE;

You need to use hook_form_alter() and on submit of the form you need to set action like this

$form["#submit"][] = "ajax_modal_form_submit";

and add function

function ajax_modal_form_submit($form,&$form_state) {
    $form_state['ajax_commands'][] = ctools_modal_command_dismiss();
    $form_state['ajax_commands'][] = ctools_ajax_command_reload();
    drupal_set_message(t("You detail submitted successfully!"));
  • I have tried but not working
    – user50991
    Aug 31, 2015 at 10:52
  • check in log messages is there any error regarding this?
    – vgoradiya
    Aug 31, 2015 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.