Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By bsears on
I cannot for the life of me figure out why my ctools_ajax_command_redirect is not working,
I had it working properly in the past but now it just does absolutely nothing (ctools_ajax_command_reload() is also broken).
Below is my ajax callback function for a form and what I want to happen is that on a successful form submission to redirect to the new node, and on a form with errors to display the errors and not allow a submission without refreshing page.
function node_create_callback(&$form, &$form_state)
{
module_load_include('inc', 'node', 'node.pages');
node_form_validate($form, $form_state);
if (!form_get_errors())
{
node_form_submit($form,$form_state);
ctools_include('ajax');
ctools_add_js('ajax-responder');
$commands[] = ctools_ajax_command_redirect("node/ ");
return array('#type' => 'ajax', '#commands' => $commands);
}
else
{
$commands = array('#type' => 'ajax', '#error' => FALSE, '#commands' => array());
$output = drupal_render($form);
$commands['#commands'][] = ajax_command_insert(NULL, $output);
// Prepend status messages to the node form.
$commands['#commands'][] = ajax_command_prepend(NULL, theme('status_messages'));
return $commands;
}
}
Comments
instead of
instead of
I would try
not redirecting
I am doing this and it doesn't works. Can anyone help me?
You probably need this:
You probably need this:
I say 'probably' because I do it myself and don't use ctools. But the above is how to return ajax commands.
Same issue
I am also facing the same. issue? any solution?
I've tried this code$path =
I've tried this code
It is working for me. But i want to open in new tab. how can i do this?
http://www.phponwebsites.com/
Hello,
Hello,
I have a similar problem
I need to redirect dynamically width query:
here is the $path displayed = accueil%26%2363%3Blocalite%26%2361%3B24148
instead of = accueil?localite=24148
www.almedestudio.com
You probably need this:
You probably need this:
I'm speculating though, as I don't use ctools.
Redirection not working
callback in modal_forms.pages.inc
Trailing Part of response as seen in browser net tab
The modal form is closed but nothing happens. If I refresh the page user is shown as logged in
This same code works on my local system where the drupal installation is in sub-directory. But does not work on LIVE server where Drupal installation is on root directory
+1
+1
Thank You,
Shashwat Purav