In many cases, the field will be used on a contact form which already provides a (required) e-mail field.

From a usability point of view, it would be a great improvement if there would be a checkbox instead of input field, and the email value would be populated from the already filled in mandatory e-mail field.

This should be possible because you can detect whether a field is an email and/or required. So a select-box could be offered:

--- email input (default, current situation)
--- use emailaddress #id

Comments

Anonymous’s picture

First, great work and great Idea! Thank you for your effort in creating this module which fills quite a gap in functionality for the regular end users.

I agree with that. In probably 90% of all cases, people would want to expose the options to select newsletters to subscribe to, using another field which provides the email adress. Another "mainstream" usage scenario is the classic "Yes I want to subscribe"-checkbox.

Like:

(contact form, name, adress, etc.)
(email field = required)

[x] Yes, I would like to subscribe to ACME Corp's Newsletter, from which I can unsubscribe at any point in time later on..

(submit)

If checked, the email adress will be subscribed to the previously defined newsletter on submit. E-Mail field has to be defined as a required field tho. The component might aswell take the last email-field which is set to be required as a default option to reduce configuration overhead and offer customisation otherwise. The email field already provides the "prefill with users email adress".

This is actually not much different than exposing all newsletters as a checkbox group, all that changes is the label of the checkbox. Things which should be configurable are which newsletters to display and the labels of each checkbox/newsletter.

Best regards!

Oliver

hotspoons’s picture

Status: Active » Patch (to be ported)
StatusFileSize
new6.51 KB

I attached a patch which should operate almost exactly as described/requested above. On the webform component editing page, the newsletters selection box is now a multi-select box; by default, you can now subscribe a person to more than one newsletter using a single text entry field by selecting multiple newsletters in the component configuration. This leaves the current visitor-facing UI the same, but allows more functionality on the back end.

There is also an option to "Allow individual selection of newsletters"; this will display a list of newsletters the visitor can subscribe to as a list of checkboxes, populated from what was selected in the component editing screen, so for instance, one webform can display the option to subscribe to newsletters A, B, and C, and another webform can display the option to subscribe to X, Y, and Z.

Please review and let me know if it works out. Thanks!

pcambra’s picture

Thanks for the patch hotspoons
As I don't really need this for my project, my test wouldn't be enough, let's see if the rest of people that were interested in this can test it and I will commit it.

Sile’s picture

Thanks for this patch hotspoons - it's functionality is exactly what I was looking for. Am testing it out - so far so good :-)

Peter76’s picture

Thanks for the patch. Its work great.

But there is just one problem. When I submit webform it shows blank page (no thank you page). Also when you confirm your subscription it shows blank page.

Anonymous’s picture

Thanks for the patch!

I gave it a try on my testsite and I think it would work rather well for a form which is focused on handling newsletter subscriptions. I didn't encounter any problems or bugs so far, seems to work well! The "page not displayed" thing from #5 doesn't happen here.

Other feedback/questions:

- I think it would be helpful to add an option which allows you to disable the built-in email-field of this module and use the standard webform-email field as source for e-mail adresses instead. This would create a much more flexible module. From a user perspective, if you are on a contact form and you need to enter your email adress twice - once for contact purposes, once for email subscription - nobody is ever gonna do that lightly, the "annoyance threshold" is a bit high. Which is bad. :-)

- Any idea how one could make it so that one could change the label of the checkbox for each item - and also show the checkbox if only 1 newsletter is selected, but with a different label? Something like "[ x ] Yes, I want to receive your news."? Like, prepopulated and piped item list in a text field instead of selection fields?

- The resulting form contents aren't listed in the webform result page (selection/adress) is that a limitation or not implemented on purpose?

freatida’s picture

The patch is working fine for me, thanks hotspoons.
The original request of this issue to have the option to have a checkbox instead of textfield for email address would be very very useful. Has anyone managed to implement this?

pcambra’s picture

Hi guys,

As I'm not going to need anymore than the current code published in the project, maybe one of you wants to take care of the project (hotspoons?) and the new features required.

Let me know what you think.

mstrelan’s picture

subscribe (+1)

mstrelan’s picture

#2 works for me, but the patch didn't apply so I had to apply the changes manually.

juliusvaart’s picture

To add the SimpleNews email address as the sender address change line 14 in "webform_simplenews.module"

from:
'email' => TRUE,

to:
'email_address' => TRUE,

Now you can use it as a 'standard' email address.

hotspoons’s picture

I'll take it on. I have a CVS account - what else needs to be done?

pcambra’s picture

Thanks hotspoons
I've granted you access to CVS so you can commit the project!

pcambra’s picture

Status: Patch (to be ported) » Fixed

Commited the patch by hotspoons, thanks
#11 that is commited as well in a previous patch today, thanks.
Marking this as fixed

Status: Fixed » Closed (fixed)

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

joecanti’s picture

Hi,
I'm using the Oct 4th dev version but I dont see an option to add this as a check box..I can only add an email field which gets filled in...am I missing something simple?

Thanks, Joe

Wallack’s picture

duped

Wallack’s picture

duped

Wallack’s picture

duped

Wallack’s picture

Ok, I solved my problem:

I wanted to be shown the checkboxes even if only one newsletter is available. Also I wanted to be able to customize the label for each newsletter.

What I've done so far (maybe someone can add it to a patch or whatever):

simplenews_admin.inc

I've created a new field under the name (line 154):

$form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Newsletter name'),
    '#size' => 50,
    '#maxlength' => 128,
    '#description' => t('The name of this newsletter.'),
    '#required' => TRUE,
    '#default_value' => isset($term->name) ? $term->name : '',
  );
  $form['simplenews_checkbox_label_'. $term->tid] = array(
    '#type' => 'textfield',
    '#title' => t('Checkbox Label'),
    '#size' => 60,
    '#maxlength' => 128,
    '#default_value' => variable_get('simplenews_checkbox_label_'. $term->tid, "Yes I would like to subscribe."),
  );

As you can see is a text to describe what would be the label of that newsletter if shown somewhere.

Same file, around line 290 (after the previous addition):

variable_set('simplenews_checkbox_label_'. $tid, $form_state['values']['simplenews_checkbox_label_'. $suffix]);

This will save the content of the field and can be retrieved.

Now with other file:

webform_simplenews.inc

Around line 156 changed this:

if (count($news_vid) > 1 && $component['extra']['individual_newsletter_selection']) {
    $options = array();
    foreach (taxonomy_get_tree(variable_get('simplenews_vid', '')) as $newsletter) {
      if ($news_vid[$newsletter->tid] != 0)
        $options[$newsletter->tid] = $newsletter->name;
    }

To this:

if (count($news_vid) > 0 && $component['extra']['individual_newsletter_selection']) {
    $options = array();
    foreach (taxonomy_get_tree(variable_get('simplenews_vid', '')) as $newsletter) {
      if ($news_vid[$newsletter->tid] != 0)
        $options[$newsletter->tid] = variable_get('simplenews_checkbox_label_'.$newsletter->tid, '');
    }

This will show the checkboxes if there are more than one newsletter and instead of the newsletter name will show the newsletter label previously added.

snlnz’s picture

Any chance of a D7 patch? :)

smitty’s picture

What's about the initial feature request?

To get a checkbox instead of input field and the email value would be populated from the already filled in mandatory (webform) e-mail field.

juliusvaart’s picture

Well, that is what this does for me... a checkbox. Works perfectly.

smitty’s picture

Then I must be doing something wrong!

With only one Newsletter I only get a e-mail-Field where I can enter the E.Mail-Address (already entered in an webform-e-email-field) again.

With two Newsletters I get an e-mail-Field and additional two Checkboxes (one for each newsletter).

juliusvaart’s picture

Did you use the comment #20 code?

juliusvaart’s picture

Maybe it's already implemented in the 6.x-Dev version...

smitty’s picture

Yes, I tried the code from comment #20.

The only thing what this code does, is to enable the checkbox even if there is only one newsletter. But it does not remove the input field for the e-mail-address.

And if you enter an e-mail-addess this address is used for the newsletter, no matter it the checkbox is checked or not.

Moreover it's not possible to get the e-mail-address from an other e-mail-field (webform).

So my result: this is not working at all!

juliusvaart’s picture

Did you change the code as described in comment #11?

smitty’s picture

This code is already in the module:

function webform_simplenews_webform_component_info() {
  $components = array();
  $components['newsletter_email'] = array(
    'label' => t('Newsletter email'),
    'description' => t('Email for newsletter'),
    'features' => array(
      'csv' => TRUE,
      'email' => TRUE,
      'required' => TRUE,
      'conditional' => TRUE,
      'email_address' => TRUE,
      'spam_analysis' => TRUE,
    ),
    'file' => 'webform_simplenews.inc',
  );
  return $components;
}
juliusvaart’s picture

StatusFileSize
new10.38 KB

Well, i've tried it again, and it's working fine.

Attached is the module i'm using.

juliusvaart’s picture

You should use the newsletter e-mail field. It works just like the webform e-mail (if code from comment #11 is used). You could populate it with a token and hide it using CSS display: none if that is what you want...

smitty’s picture

How can I populate the newsletter e-mail field?

As far as I webform does not provide any tokens and the newsletter e-mail field does not have a input filed to insert a token.

juliusvaart’s picture

I see, the Newsletter E-mail field doesn't have a field for Default value... won't be really hard to implement i think.

In your first post you write:

"the email value would be populated from the already filled in mandatory (webform) e-mail field."

But you can replace the standard Webform e-mail field (i believe that s what you are referring to with the mandatory field) with the Newsletter e-mail field and use that as the standard e-mail field (instead of the one you already had, so you can delete that one).

Or do you need other functionality? Maybe i don't understand...

smitty’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

I've tested your module from #30 on a new D6-Installation and this works fine, indeed! Thank You!

So it must be a version-issue, since I am using D7. Because this port was done after #14 I thought that this should also work for D7. Apparently a wrong conclusion.

The issue in D7 is - after all - that a confirmation e-mail is sent, no matter if the checkbox is checked or not.

A minor issue (even in D6) could be, that it would be nice if we could see in the results if the Checkbox was checked or not.

I will go into the code and have a look what changed between D6 and D7. But I need a few days for that, because I have to do other things first.

juliusvaart’s picture

Category: feature » bug
Status: Closed (fixed) » Active

I haven't had the need for this module in D7. Would be great if you'd post a patch!

Kind regards, Julius

drupa11y’s picture

Another cool feature would be the possibility to sort the order of the newsletters.

smitty’s picture

Status: Active » Fixed

All I had to do, was to apply the code from Checking no newsletter will subscribe to all to function _webform_submit_newsletter_email.

Now it works fine!

Could someone commit the change from #20 to the D7-branch please?

snlnz’s picture

Can this or has this been patched to the d7 branch? I don't see the option of a check box for newsletters with the latest dev release?

Status: Fixed » Closed (fixed)

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

snlnz’s picture

Status: Closed (fixed) » Active

Can this be re-opened until confirmation that it exists in D7 branch?

RunePhilosof’s picture

Status: Active » Patch (to be ported)
techman-1’s picture

Greatly appreciate the work and time from the developers on this module.
This thread goes back many years through multiple builds of this module and Drupal.
Can anyone elaborate and post up-to-date and concise instructions on how to add the single checkbox feature. I have a webform and I just want to provide a single checkbox for the visitor where a checked box adds the e-mail address they submit to the list of subscribers for my Simplenews newsletter.
Thanks!