concrete5/concrete5 — pull request #748 by jordanlev (2012-11-13 22:00:19+00:00)
Title: fix redirect bug in form block AND handle ajax submissions better

At the end of the `action_submit_form()` function...

1. In the `if($this->redirectCID > 0)` section, it was checking for a nonexistent page with `is_object($pg)` -- but this is *not* the proper way to check for a nonexistent page (because Page::getByID *always* returns an object -- but with a null cID if nonexistent).

2. Moved the redirect stuff to inside the "if" check for `noSubmitFormRedirect` -- because if you set noSubmitFormRedirect to TRUE, it means you do not want the form to redirect (even if user chose a page). Usually this is for ajax form submissions, and setting header('Location...') doesn't do anything for ajax requests.

3. I DRY'ed up the code by not repeating the redirect-back-to-same-page logic when chosen page is not found.

4. Removed commented-out `REQUEST=array()` code (has nothing to do with the above, but I saw it and decided it should be cleaned up -- broken windows theory and all that).