Download & Extend

Form action is set to AHAH path instead of form real form path

Project:AHAH helper
Version:6.x-6.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (duplicate)
Issue tags:ahah issue

Issue Summary

Get the following error on the demo form and my own form with the following steps.

1. Select a form element that does AHAH generation.
2. Click submit without filling in required fields
3. Error message is displayed stating what is missing, then click submit again.
4. You get a screen with the below message only.

{ "status": true, "data": "\x3cdiv class=\"messages error\"\x3e\n \x3cul\x3e\n \x3cli\x3eFirst name field is required.\x3c/li\x3e\n \x3cli\x3eLast name field is required.\x3c/li\x3e\n \x3cli\x3eAddress field is required.\x3c/li\x3e\n \x3c/ul\x3e\n\x3c/div\x3e\n\x3cdiv id=\"billing-info-wrapper\"\x3e\x3cfieldset\x3e\x3clegend\x3eBilling information\x3c/legend\x3e\x3cdiv class=\"form-item\" id=\"edit-billing-info-usage-wrapper\"\x3e\n \x3clabel for=\"edit-billing-info-usage\"\x3eUsage: \x3c/label\x3e\n \x3cselect name=\"billing_info[usage]\" class=\"form-select\" id=\"edit-billing-info-usage\" \x3e\x3coption value=\"private\" selected=\"selected\"\x3ePrivate\x3c/option\x3e\x3coption value=\"company\"\x3eCompany\x3c/option\x3e\x3c/select\x3e\n\x3c/div\x3e\n\x3cinput type=\"submit\" name=\"op\" id=\"edit-billing-info-update-usage\" value=\"Update usage\" class=\"form-submit no-js\" /\x3e\n\x3cdiv class=\"form-item\" id=\"edit-billing-info-first-name-wrapper\"\x3e\n \x3clabel for=\"edit-billing-info-first-name\"\x3eFirst name: \x3cspan class=\"form-required\" title=\"This field is required.\"\x3e*\x3c/span\x3e\x3c/label\x3e\n \x3cinput type=\"text\" maxlength=\"255\" name=\"billing_info[first_name]\" id=\"edit-billing-info-first-name\" size=\"20\" value=\"\" class=\"form-text required error\" /\x3e\n\x3c/div\x3e\n\x3cdiv class=\"form-item\" id=\"edit-billing-info-last-name-wrapper\"\x3e\n \x3clabel for=\"edit-billing-info-last-name\"\x3eLast name: \x3cspan class=\"form-required\" title=\"This field is required.\"\x3e*\x3c/span\x3e\x3c/label\x3e\n \x3cinput type=\"text\" maxlength=\"255\" name=\"billing_info[last_name]\" id=\"edit-billing-info-last-name\" size=\"20\" value=\"\" class=\"form-text required error\" /\x3e\n\x3c/div\x3e\n\x3cdiv class=\"form-item\" id=\"edit-billing-info-address-wrapper\"\x3e\n \x3clabel for=\"edit-billing-info-address\"\x3eAddress: \x3cspan class=\"form-required\" title=\"This field is required.\"\x3e*\x3c/span\x3e\x3c/label\x3e\n \x3cinput type=\"text\" maxlength=\"255\" name=\"billing_info[address]\" id=\"edit-billing-info-address\" size=\"20\" value=\"\" class=\"form-text required error\" /\x3e\n\x3c/div\x3e\n\x3cdiv class=\"form-item\" id=\"edit-billing-info-country-wrapper\"\x3e\n \x3clabel for=\"edit-billing-info-country\"\x3eCountry: \x3c/label\x3e\n \x3cinput type=\"text\" maxlength=\"255\" name=\"billing_info[country]\" id=\"edit-billing-info-country\" size=\"20\" value=\"\" class=\"form-text\" /\x3e\n\x3c/div\x3e\n\x3c/fieldset\x3e\n\x3c/div\x3e", "settings": { "ahah": { "edit-billing-info-usage": { "url": "/~jbrown/20ci/?q=ahah_helper/billing_info", "event": "change", "keypress": null, "wrapper": "billing-info-wrapper", "selector": "#edit-billing-info-usage", "effect": "none", "method": "replace", "progress": { "type": "throbber" }, "button": false } } } }

Comments

#1

I've seen this type of response as well in that exact situation.

You may want to check if your submit buttons use drupal_get_destination() to build the submit url. If so you will get the wrong destination url if a ahah event happened before the submit. I was getting exactly this type of error until I got rid of the call to drupal_get_destination().

Easy to check. After the ahah call check what url gets generated for the form submit.

Good luck hope that helps.

#2

I had a similar error with file field uploads and ahah... i updated my jquery.form plugin and that fixed my issue. See: http://drupal.org/node/473760#comment-2253936

#3

Title:Craps out on Form errors (HIGH PRIORITY)» Form action is set to AHAH path instead of form path when fails validation

I have the same problem. The form has this markup before:
<form id="subscription-form" method="post" accept-charset="UTF-8" action="/subscribe">
And this after failing validation:
<form id="subscription-form" method="post" accept-charset="UTF-8" action="/ahah_helper/WHATEVER">
Note that this only happens if I activate ahah in the form. If I submit the form without touching any ahah element, I get the usual validation error but the action attribute is untouched.

#4

Found a hacky solution here: http://drupal.org/node/371339

#5

Status:active» closed (duplicate)

This is a duplicate of #578252: $form["#action"] gets set to /ahah_helper/path (with patch to fix!).

See that issue for a patch that fixes the problem.

#6

Title:Form action is set to AHAH path instead of form path when fails validation» Form action is set to AHAH path instead of form real form path
Project:AHAH helper» AHAH Fragment
Version:6.x-6.x-dev» 5.x-1.x-dev

I alert registration from use on ahah=>path is zone/js

global $user;
$form_state = array('storage' => NULL, 'submitted' => FALSE);
$form_build_id = $_POST['form_build_id'];
// Get the form from the cache.
$form = form_get_cache($form_build_id, $form_state);
$args = $form['#parameters'];
$form_id = array_shift($args);
// We will run some of the submit handlers so we need to disable redirecting.
$form['#redirect'] = FALSE;
// We need to process the form, prepare for that by setting a few internals
// variables.
$form['#post'] = $_POST;
$form['#programmed'] = FALSE;
$form['#submit'] = FALSE;
$form_state['post'] = $_POST;
$form_state['action'] = $form['#action']="/home";
drupal_process_form($form_id, $form, $form_state);
$form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
// Render the new output.
if($user->uid){
$choice_form = $form['Contact']['profile_state'];
}else{
$choice_form = $form['account']['location']['profile_state'];
}
unset($choice_form['#prefix'], $choice_form['#suffix']); // Prevent duplicate wrappers.
$output = drupal_render($choice_form);
drupal_json(array('status' => false, 'data' => $output));

after complete from than it change form action so my form is submit on zone/js path while it should be submit on user/register please suggest me
i user drupal 6
thax
Anil kumar rawar
anil@osscube.com

#7

Project:AHAH Fragment» AHAH helper
Version:5.x-1.x-dev» 6.x-6.x-dev

Not sure you meant to move this issue to a different project.

#8

nobody click here