Hello,
I'm currently working on a site where one can sign up for an event. The page content is structured into three horizontal tabs with the help of the Fieldgroup module. The Webform is on the third tab, so the full url becomes http://mysite.com/event/event-name#webform. On a form validation error however the page returns to page without taking into account the URL fragment (so: http://mysite.com/event/event-name). If I click again on the third tab, then I can see that all other validation functions worked perfectly, so the user's input is preserved and the error messages are shown, but the form is invisible since the user is returned to the "wrong part" of the page.
My question: should the validation of a webform take a URL fragment into account or is the behaviour described above by design?
In the meantime, I'm trying to solve this by trying to hook into the form validation function by this code in a custom module:
function ay_webform_form_alter(&$form, &$form_state, $form_id) {
// Affect all Webform forms.
if (substr($form_id, 0, 20) == 'webform_client_form_') {
$form['#validate'][] = 'ay_webform_form_validate';
}
}
function ay_webform_form_validate(&$form, &$form_state) {
// Redirect page to correct part
$current_url = url(current_path(), array('absolute' => TRUE));
drupal_goto($current_url . '#webform');
}
On a validation error it returns to the correct part of the page, however the user's input isn't preserved. Unfortunately I don't have enough understanding of the inner workings of the Webform module to know how I can handle this correctly. Can you point me into the right direction?
Comments
Comment #1
SidneyGijzen commentedComment #2
danchadwick commentedWe don't supply custom programming support in this issue queue. Good luck.