I've set up 2 newsletters with blocks to subscribe. The first newsletter works fine but when I click the subscribe button on the second newsletter it un-subscribes me from the first one instead. I've added a third to test and it does the same. Basically each button acts like it belongs to Newsletter 1.

The HTML for the blocks show identical values for all "form-token":

input name="form_token" id="edit-simplenews-block-form-form-token" value="8071f21a1c828234f66774e0c3c88dbd" type="hidden" 

???

CommentFileSizeAuthor
#17 simplenew.273218_D5.patch2.06 KBsutharsan

Comments

j4h8’s picture

Anybody any ideas on this? Same problem here.
The blocks have the same form_id and form_token. Only the div id of the blocks are different.

Thanks in advance!

atrayu13’s picture

I would like to add my voice to those having this problem.... if anyone has any idea how to fix this, i would greatly appreciate it!

number3’s picture

Priority: Normal » Critical

Yes, I'm having similar problems as well.

I have two newsletter blocks. When an unauthorized user subscribes to the second block the $tid passed is the taxonomy id of the first (default) newsletter and not the second one.

The printed forms are distinguished (meaning they are separate instances), however when the form gets validated/submitted, the first taxonomy id is submitted and used. So it will always send a confirmation e-mail for the wrong newsletter subscription.

I'm currently trying to fix the issue, but it would be nice if this bug was fixed by the authors.

mightyiam’s picture

sutharsan’s picture

Status: Active » Postponed

I agree this is a bit hacky. Did you try it?
I have no solution on this bug yet. I investigated it before but without result. I recognize the problem but looking at the frequency of request for it I postpone it to D6, in which I believe we can solve this problem.

mightyiam’s picture

I think what we are talking about is http://drupal.org/node/111719.

sutharsan’s picture

Whenever you have multiple subscription bocks on one page, simplenews always acts as if you subscribed/unsubscribed in the first newsletter block. It all comes back to the id of < form > not of the submit button. in D5 the form-id is generated by forms-api and is always equal to the form functionname. If one function generates multiple forms on the same page. At form submission there is no way to differentiate between the two forms because it is the same form (based on the id). D6 does have the possibility to route the form submission (http://drupal.org/node/144132#buttons).

atrayu13’s picture

Thank you all for the information.

Based on what you said, I put each newsletter block on it's own page, and that solved the problem.

It would be nice to be able to have all of the newsletter blocks on the same page, but this will work out just fine as well. as long as the module works.

tomx’s picture

Did someone solved this problem?

number3’s picture

Unfortunately I wasn't able to fix it like I would have, I just made a work around it. The client I'm working for didn't want the blocks and suggested that I make a separate page to manage subscriptions to multiple newsletters. So I was kind of lucky they didn't want the blocks.

xen’s picture

I just got bitten by this, so I'll just add my thoughts...

#6: No, that's about id's, which doesn't actually affect form submission.

#7 You're on the right track, but I don't think the button routing is a solution as such.

As people has suggested, the problem is that both forms has the same form_id, which FAPI grabs the first form defined, and submits that. The problem isn't as much in the fact that it's the same form, as it is in the fact that the tid of the newsletter is embedded in the form as a '#type' => 'value', which make FAPI store it on the server and never get passed to the client.

So I though it fix it by changing it to a 'hidden' field instead, which should make FAPI grab it from the submission instead, and thereby allow the submit function to know what newsletter to subscribe to.

However, that didn't work for me, I can't figure out why, and I didn't have the time to work on it. Maybe someone else can try, and see if I was just being stupid.

sutharsan’s picture

Not that it will help you immediately, but I solved this problem for the Drupal 6 version of Simplenews. I got the solution form poll module. But poll module in Drupal 5 uses the nid from the url to identify the right form. So unfortunately that trick can not be used for the subscription block.

number3’s picture

Sutharsan, could you detail how you got the problem solved for Drupal 6? Thanks.

sutharsan’s picture

In the block form the tid is stored in $form['#tid'] like this:

function simplenews_block_form(&$form_state, $tid) {
  ...
  $form['#tid'] = $tid;
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => isset($submit_text) ? $submit_text : t('Save')
  );
  return $form;
}

In the _submit function $tid is collected from $form['#tid'] like this:

function simplenews_block_form_submit($form, &$form_state) {
  global $user;
  $tid = $form['#tid'];
  ...
}

This very same thing is not possible in Drupal 5 FAPI, but perhaps, number3, it is of some use to you.

sutharsan’s picture

Version: 5.x-1.1 » 6.x-1.x-dev
Status: Postponed » Fixed

This problem has been fixed now in the 6.x-1.x-dev version. Please have a look.
The solution can not be back-ported to simplenews 5.x-1.x-dev since the solution has been made possibly by the change in forms API in Drupal 6.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

sutharsan’s picture

Version: 6.x-1.x-dev » 5.x-1.x-dev
Status: Closed (fixed) » Fixed
StatusFileSize
new2.06 KB

Based on a new solution for Drupal 6 (http://drupal.org/node/273218) I was able to fix this bug in 5.x-1.x-dev too.

The patch committed and attached for reference.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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