Domanda

I am using Drupal 7.15, and have a Webform setup as a block that gets included on the Contact page (a basic page). The basic Contact page has editable sidebar content and then the Webform block as the main content. The problem I am having is on submission the Webform goes to its own alias 'general-inqueries' rather than the Contact us alias 'contact-us'. I want it to return to the basic page Contact Us with any validation errors and/or confirmation message.

It seems the form action is always the Webform alias, however when I try to change the alias to the basic page Contact Us alias (contact-us), it says this alias is already in use.

Without creating a separate page for errors or success confirmation, how can I modify the action to return to the original page with any messages on submit? I would prefer not to us JS to set the form action after the fact. That might not even help me anyway if the error/success messages are not passed to it.

Here is the testing server if you would like to take a look:

http://69.160.59.20/contact-us

Any and all help is much appreciated!

Thanks all

È stato utile?

Soluzione

Form actions can be set using a form_alter hook. Something like:

my_module_form_alter($form, $form_state, $form_id) {
  if ($form_id == 'webform_id_form') {
    $form['#action'] = url('comment/reply/'. $edit['nid']);
  }
}

If you are using Drupal 7 skip the form id check and try:

my_module_form_form_id_alter($form, $form_state) {
}

if you don't know how to find the form id just use the above function with a print statement:

my_module_form_alter($form, $form_state, $form_id) {
  print($form_id);
}

and the form id will be the one with the word webform in it.

More details on the form api here: http://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7#action

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top