Hey, this is my first time developing for Drupal, and I needed an AHAH form item and borrowed the one from the Poll module, but I found a major bug in that specific module that can be reproduces every time following the steps below.

1) On the poll module form, do not put in a title, and fill in the two choices
2) press save/preview, and let the validation error occur, it'll highlight the title field
3) Now fill in the title field, and it should be fine? right?
4) But! instead when u press save/ preview and it will not let u save or preview, but redirect you to the Json page poll/js

http://masi1.webs.com/index.htm <-- bug report with screen shots

This is a really frustrating bug since I used the same AHAH component on my own large form, where the chances of some1 missing something is significantly higher. Every time a validation error occurs, the entire thing blows up... and since i'm relatively new at Drupal... it'll take up too long fixing it by just by myself, (AHAH is rlly complicated for me at the moment)

My personal idea would be to, use hook_submit() to try and catch the redirect or hook_form_alter() to force the form to stay?
If any1's already figured this out, or if this issue has been resolved a long time ago before, any links or code ideas would be really helpful!

Comments

Swayt’s picture

sry note for step one, sometimes you may need to add an extra choice field, (this means filling in a title, add a choice, erase it for a validation error) ... but other times, it'll redirect to the poll/js straight away

Swayt’s picture

Status: Active » Needs work
Swayt’s picture

Priority: Critical » Minor
Status: Needs work » Fixed

FIXED

Very easy fix but takes a long time to find, the information was found in this post comment: http://drupal.org/node/524220#comment-1848070

basically, at the end of the poll form declaration, just add

$form['#action'] = $node->path;

the exact facts are explained in the comment link. :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

lizac’s picture

hi. can you provide more info on where exactly is the end of poll form declaration? Is it in poll.module? Sorry to ask, I'm just new in Drupal. thanks!

Swayt’s picture

Hey, I'm glad my post helped someone... lets see the end of the poll form is in poll.module... just scroll down to the file until you see the comment /*Implementation of hook_form() */. That's where your going to need to place that piece of code.

/**
 * Implementation of hook_form().
 */
function poll_form(&$node, $form_state) {
  global $user;

  ..... 
  .....
  .....

  $form['settings']['runtime'] = array(
    '#type' => 'select',
    '#title' => t('Poll duration'),
    '#default_value' => isset($node->runtime) ? $node->runtime : 0,
    '#options' => $_duration,
    '#description' => t('After this period, the poll will be closed automatically.'),
  );

  $form['#action'] = $node->path;  // Place it here

  return $form;
}

This should solve your problems with the poll module. GL!

lizac’s picture

Hi! Thank you for your response. It really means a lot. We are fixing some things on our prod site and I can't apply it now. Nevertheless, I'm really hoping that this could solve the problem we have in using core poll module.

Just to give you an idea, my problem is explained here - http://stackoverflow.com/questions/3922650/drupal-core-poll-http-403-error and http://drupal.org/user/639290. This may not be the exact problem as yours but I would love to give it a shot and try my luck. This error is giving me a lot of frustrations. =(

If you could also find time to check on the issue I posted, I will truly appreciate it. Thanks again!!!

damien tournoud’s picture

Category: bug » support
Status: Closed (fixed) » Closed (works as designed)

As far as I know, the poll module works correctly. This is a configuration issue (probably a wrong base URL).