0

I have a website in drupal 7. I used advanced form block module to create add form block. Advanced form block module create block for form to edit and add new content. All node saved by ajax submission.

I want to redirect the user when new node save by this form. I used rules and form[#redirect] method in my hooks, but these are not working.

Can any one help me to figure out this?

Thanks

1

A form[#redirect] will not work in an AJAX form.

You can use an AJAX redirect command from CTools: ctools_ajax_command_redirect

To do this, you should probably have to alter the form and use your own callback function returning the ajax command (along other needed data). I don't know advanced form block module so I can't say how difficult it is.

Example from http://dropbucket.org/node/1236:

  ctools_include('ajax');
  ctools_add_js('ajax-responder');
  $commands[] = ctools_ajax_command_redirect($path);
  print ajax_render($commands);
  • When I use this it will alert the whole page. I already tried this. I added exit in the last but it will redirect the page but not save the node in the database. – Gaurav Sharna Aug 13 '14 at 11:47
  • If you use exit you cut the execution flow and the submit handler is not executed, so node is not saved. I think your are not returning the AJAX command correctly. – sanzante Aug 13 '14 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.