Hello,

I want use tablefield module for my site. But, i get an error when i create a table in the node page admin :

"warning: Invalid argument supplied for foreach() in /var/www/vhosts/xxxxxxxxx/httpdocs/sites/all/modules/cck/modules/content_multigroup/content_multigroup.node_form.inc on line 397"

Do you have a solution?

Thanks.

CommentFileSizeAuthor
#1 cck-buttonsubmitfix-1281450-1.patch841 bytesinfiniteluke
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

infiniteluke’s picture

Version: 6.x-3.0-alpha3 » 6.x-3.x-dev
Status: Active » Needs review
FileSize
841 bytes

I was seeing this error when a "button" form element on a form containing a multigroup was pressed. In my case "Rebuild Table" from the tablefield module was rebuilding the form and refreshing the page to change a table size. This obviously also causes validation as well.

When a form is submitted to be saved $form_state['submitted'] is set to true and _content_multigroup_node_form_after_build runs a few functions to clean up the $form_state array. The same after build function runs in the example above, but because the $form_state['submitted'] is false in that case, the validation function gets passed a malformed $form_state array.

Changing..
if ($form_state['submitted'] && !$form_state['multigroup_add_more']) {

to

if (($form_state['submitted'] || $form_state['clicked_button']) && !$form_state['multigroup_add_more']) {

in _content_multigroup_node_form_after_build should cover this case.

Cross-referencing a similar issue: #730154: Multigroup fields no longer saving; error in content_multigroup.node_form.inc on line 369.
Not sure if these are duplicates. It could be a separate issue.

To test this you can form alter a form with a multigroup on it and add a "button" form element. Click the button and see if this error occurs. Apply the patch and try clicking the button again. Or you could test with the tablefield module.

infiniteluke’s picture

Title: Error with Tablefield Module » Clicking custom submit/button form element causes error in multiselect validation

Better title