I use pollfield in forum. I find something wrong, I cannot add more poll choices. It displays the error as below.

MESSAGE Notice: Undefined index: in pollfield_more_choice_callback_js() (line 463 of /public_html/sites/all/modules/pollfield/pollfield.module).

Please help me


PierreSoft’s picture

tambien tengo ese problema, lo podran corregir, veo que no le hacen mantenimiento a este modulo hace tiempo

trillex’s picture

I didn't get that exact error message, but a workaround is to save the node and then edit it. You should be able to add more choices now.

zonesny’s picture

Issue tags: +pollfield, +7.x-2.x

Hi. Per joezine's previous post, I believe the problem lies in the AJAX callback function, pollfield_more_choice_callback_js().

$form_choices is supposed to be assigned the value of the ['group'] element (i.e. an array containing the poll choice arrays i.e. fieldsets). This is not happening.

	$field_name = $form_state['field_name']; //this returns a correct value i.e. machine name of your pollfield field from content type's "Manage Fields" tab 
	$field_lang = $form_state['field_lang']; //this is empty!
	$field_delta = $form_state['field_delta']; //this returns a 0, presumably the first item and not FALSE
	$form_choices = $form[$field_name][$field_lang][$field_delta]['group']; //this is empty! I tried $form_state as well

In pollfield_field_widget_form() (around line 368), $field_lang has no value after assignment:


I believe the "Undefined index" error (and "Cannot use field offset as an array" error) are both related to the fact that $field_lang is empty (and subsequently, so is $form_choices). Here is an decent explanation for these types of errors. (NOTE: Even after specifically assigning a proper value to $form_state['field_lang'], $form_choices was still empty.)

After I modified the code and assigned $form_choices an actual array (based on the $widget['group'] form in pollfield_field_widget_form(), around line 275), the additional poll choices were added to the wrapper div, as expected (with the exception of the input fields, likely due to a missing property on my part).

The Drupal 7 function ajax_command_insert() could be used to update the form with the additional poll choices, but again, the ['group'] element will need to be accessed.

Thoughts? Fixes? Maintainers?