How to close (ctools) modal node/add form after submit? I wrote this module that print the node/add form for a content type (article) in a ctools modal window. It works and the new node is saved, but the modal window remains opened after submitting the form.

I would like to automatically close the modal window after saving the node, end and optionally redirect drupal to the new node. Any hint?

      &lt;?php


    function modaltest_menu()
    {
    $items['modaltest']            = array(
        'title' =&gt; 'Modaltest Page',
        'page callback' =&gt; 'modaltest_page',
        'access arguments' =&gt; TRUE
    );
    $items['modaltest/%ctools_js'] = array(
        'title' =&gt; 'Modaltest page 2',
        'page callback' =&gt; 'modaltest_page_modal',
        'page arguments' =&gt; array(
            1
        ),
        'access arguments' =&gt; TRUE
    );
    return $items;
}


      function modaltest_page_modal($js = NULL)
    {
      $nojs_message = t('Hello World');
    if (!$js) {
        return $nojs_message;
    }
    module_load_include('inc', 'node', 'node.pages');
    $form = node_add('article');
    ctools_include('modal');
    ctools_include('ajax');
    $output   = array();
    $output[] = ctools_modal_command_display(t('My modal test'), $form);
    print ajax_render($output);
    exit();
}


    function modaltest_page()
    {
    ctools_include('modal');
    ctools_include('ajax');
    ctools_modal_add_js();
    return ctools_modal_text_button(t('Popup link'), 'modaltest/nojs',      t('test popup'), 'ctools-modal-test-style');
    }
ctools_modal_command_dismiss() will close the modal.

You can find more information on that command and ctools modals in general by installing the Advanced Help module and visiting /help/ctools/modal.