I am running Webform 7.x-3.9 and Webform Simplenews 7.x-1.x-dev

I have placed the component into my web form and every time the user submits the form I get these errors:

# Notice: Undefined index: render element in theme() (line 811 of /home/boycombe/public_html/includes/theme.inc).
# Notice: Undefined index: element in theme_webform_display_newsletter_email() (line 281 of /home/boycombe/public_html/sites/all/modules/webform_simplenews/webform_simplenews.inc).
# Notice: Undefined index: #format in theme_webform_display_newsletter_email() (line 283 of /home/boycombe/public_html/sites/all/modules/webform_simplenews/webform_simplenews.inc).
# Notice: Undefined index: render element in theme() (line 811 of /home/boycombe/public_html/includes/theme.inc).
# Notice: Undefined index: element in theme_webform_display_newsletter_email() (line 281 of /home/boycombe/public_html/sites/all/modules/webform_simplenews/webform_simplenews.inc).
# Notice: Undefined index: #format in theme_webform_display_newsletter_email() (line 283 of /home/boycombe/public_html/sites/all/modules/webform_simplenews/webform_simplenews.inc).
# Notice: Undefined index: render element in theme() (line 811 of /home/boycombe/public_html/includes/theme.inc).
# Notice: Undefined index: element in theme_webform_display_newsletter_email() (line 281 of /home/boycombe/public_html/sites/all/modules/webform_simplenews/webform_simplenews.inc).
# Notice: Undefined index: #format in theme_webform_display_newsletter_email() (line 283 of /home/boycombe/public_html/sites/all/modules/webform_simplenews/webform_simplenews.inc)

CommentFileSizeAuthor
#18 webform_undefined_error-1097428-17.patch761 bytestostinni

Comments

pcambra’s picture

Status: Active » Postponed (maintainer needs more info)

I'm not sure of how to reproduce this, maybe the newsletter email is not required for you? Can you provide more details on how to reproduce this error?

Francis47’s picture

@Trickar:
I had the exact same issue on the exact same lines of code when using the block provided by Webform Simplenews Component.
There seemed to be no workaround for it, so i eventually used the block provided by Simplenews itself.
All there was to it was changing permissions for anonymous users, and a submit form appeared in the block.

I have no clue wether or not Webform Simplenews Component is required for this action or not.
But this approach worked for me.

Now i just need to figure out where to manage the subscriptions.
There seems to be no list to be found anywhere in the UI - but thats another topic.

Best regards

damiandab’s picture

Status: Postponed (maintainer needs more info) » Active

After adding the form component "newsletter email" to the webform I get another message:

Notice: Undefined index: private in webform_component_edit_form() (line 430 of /var/www/vhosts/drupaltemple.com/httpdocs/exhibitionpilot/sites/all/modules/webform/includes/webform.components.inc).

damiandab’s picture

After submitting I get a notice:

Notice: Undefined index: render element in theme() (line 824 of /var/www/vhosts/drupaltemple.com/httpdocs/exhibitionpilot/includes/theme.inc).
Notice: Undefined index: element in theme_webform_display_newsletter_email() (line 281 of /var/www/vhosts/drupaltemple.com/httpdocs/exhibitionpilot/sites/all/modules/webform_simplenews/webform_simplenews.inc).
Notice: Undefined index: #format in theme_webform_display_newsletter_email() (line 283 of /var/www/vhosts/drupaltemple.com/httpdocs/exhibitionpilot/sites/all/modules/webform_simplenews/webform_simplenews.inc).
Notice: Undefined index: render element in theme() (line 824 of /var/www/vhosts/drupaltemple.com/httpdocs/exhibitionpilot/includes/theme.inc).
Notice: Undefined index: element in theme_webform_display_newsletter_email() (line 281 of /var/www/vhosts/drupaltemple.com/httpdocs/exhibitionpilot/sites/all/modules/webform_simplenews/webform_simplenews.inc).
Notice: Undefined index: #format in theme_webform_display_newsletter_email() (line 283 of /var/www/vhosts/drupaltemple.com/httpdocs/exhibitionpilot/sites/all/modules/webform_simplenews/webform_simplenews.inc).

kenppx’s picture

I also have same issue.

carwin’s picture

subscribe

arne.olafson’s picture

I got that error when I already had a field named "email"
The error went away after I deleted the first regular email field

carwin’s picture

I'm pretty sure the solution to #7 isn't the source of the issue since I get this on new sites without ever having an initial "email" field attached to a webform. I think many of us are trying to use this so that we can collect other information along with newsletter subscriptions, like the user's name for instance. Are there any other modules that accomplish this with simplenews other than webform and this component?

This issue has been open since March with little or no visible progress.

pcambra’s picture

This issue has been open since March with little or no visible progress.

As I always answer to these kind of issues, patches are really welcome.

carwin’s picture

Let's get a list going of all the issues needed to move forward on a stable release. I'm pretty busy this week and weekend, but I'd like to help tackle this if I can.

pcambra’s picture

Status: Active » Fixed

Finally I could trace this error, and committed a fix for it.

Status: Fixed » Closed (fixed)

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

ovonzio’s picture

I'm receiving the same error as #3: Notice: Undefined index: private in webform_component_edit_form() (linea 431 di C:\xampp\htdocs\gabbris\sites\all\modules\webform\includes\webform.components.inc).

pcambra’s picture

#13 please make sure you're using the latest -dev version and if so, reopen this issue or open a new one with the steps to reproduce it.

lalit774’s picture

i got same error.

Please replace following line.

version 7.x-4.0-alpha1

FILE: webform/includes/webform.components.inc
LINE NO 442

'#default_value' => ($component['extra']['private'] == '1' ? TRUE : FALSE),

with

'#default_value' => (isset($component['extra']['private']) && $component['extra']['private'] == '1' ? TRUE : FALSE),
criznach’s picture

It looks like the private attribute is being set to 0 on line 28 in the latest dev release. In theory, that should fix this bug. I'm not using this module, but setting the private attribute in the defaults hook fixed it for me in a client module. Can anyone confirm and close?

The solution in #15 should work, but we could also update the documentation to say you MUST set the private attribute to either 0 or 1 in the defaults hook.

dimmech’s picture

Had this same issue when adding a name field in a from.

Notice: Undefined index: private in webform_component_edit_form() (line 448 of .../includes/webform.components.inc).

I can confirm the fix in #15 as well

tostinni’s picture

Project: Webform Simplenews Component » Webform
Version: 7.x-1.x-dev » 7.x-4.x-dev
Component: Miscellaneous » Code
Status: Closed (fixed) » Needs review
StatusFileSize
new761 bytes

Unless the private property is marked as required in the webform API, I think this should be patched directly into webform to avoid theses notices.
I made a patch from #15 to get it into webform.

quicksketch’s picture

Project: Webform » Webform Simplenews Component
Version: 7.x-4.x-dev » 7.x-1.x-dev

Unless the private property is marked as required in the webform API, I think this should be patched directly into webform to avoid theses notices.

If your Webform component doesn't allow the component to be used as a private field, you should set 'private' => FALSE in hook_webform_component_info(). Otherwise in you component's _webform_component_[type]() function you should the default. We specifically provide tools to prevent the need to use isset() checks all over the place and the individual components should define defaults if necessary.

rootwork’s picture

Was the patch in #18 applied to the dev branch? I have the latest stable release and it wasn't there, and since this was all I needed I just applied the patch. But if it is present in the dev branch it would be nice to roll it into a forthcoming stable release.

rootwork’s picture

I should specify that I was getting this error without any involvement of Simplenews (I don't have that module installed), which is why the Webform patch seemed like the right course. Specifically I was getting the Notice: Undefined index: private in webform_component_edit_form() error.

sanitaM’s picture

I have multiple newsletters enable, and the option to select them individually

#18 did not work for me. (7.x-1.x-dev)

I have multiple errors :(

Notice: Undefined index: 1249 in _webform_render_newsletter_email() (line 142 of /xxxx/www/root/sites/all/modules/webform_simplenews/webform_simplenews.inc).

Notice: Undefined index: 1250 in _webform_render_newsletter_email() (line 142 of /xxxx/www/root/sites/all/modules/webform_simplenews/webform_simplenews.inc).

Do you have any recommendations?

sanitaM’s picture

I solved the problem with an Undefined index in line 142 of webform_simplenews.inc.

I am running Webform Simplenews 7.x-1.x-dev and Webform 7.x-3.20.
I have multiple newsletters enable, and the option to select them individually.

My little patch is:

webform_simplenews.inc
line 142

-   if ($news_vid[$newsletter->tid] != 0) {
+    if (isset($news_vid[$newsletter->tid]) != 0) {