I have a situation that if my form doesn't validate I need it to remove all but the first argument from the url. The reason for this is because the results of my form are displayed below the form in the content area. If the form doesn't validate I need to remove any previous results.
I am have tried the following in my form_validate function.
// Check if there were any errors.
$errors = form_set_error();
if (!empty($errors)) {
drupal_goto(arg(0));
}
The destination page obviously is the same except that all arguments, except the first, are stripped. The problem is that Drupal forgets about the previous form state and the errors that were raised by the form_validate function.
I have also tried to change the #redirect value in my form_validate function but to no avail.
Any suggestions?