I was getting a 'bad arguments' php error for implode around line 211. I'm using subform_element with the addnode CCK module and I only have one node-type available to choose from. My guess is that form['#parents] isn't an array in this case which causes the error. I didn't really dig around the code much because I fixed it for my situation so quickly. Here's what I did:

Starting at line 210:

      elseif(is_array($form['#parents'])) {
        $form['#name'] = $prefix. '['. implode('][', $form['#parents']) .']';
      }else{
        $form['#name'] = $prefix. '['. $form['#parents'] .']';
      }

(I'm having issues creating good patches right now otherwise I would have attached one)

Because subform_element is used with other modules this solution may or may not be for everyone. I just thought I'd share it.

Comments

fago’s picture

Project: Subform Element » Addnode
Version: 5.x-1.x-dev » 5.x-1.2

hm, I think usually the parents has to be an array at this stage of form processing.
So the question better is - why it is not?

To clarify this, we need to know how it is invoked and for which form element the error occurs.
So I set to addnode, to gather more information. (the bug might be in both modules)

mykle’s picture

I'm having the same problem in Drupal 5.3. I have traces turned on in the devel module, so I have a complete stack trace for this. However, it's quite large and sort of strangely-formatted after i cut and paste it. But i'll try. (Wherever it says ($form), that's the form array, which is quite vast.)
The original error seems to be that the second argument to implode() is null/undef.

warning: implode(): Bad arguments. in /home/mykle/mun3/www/modules/subform_element/subform_element.module on line 211.

implode	/home/mykle/mun3/www/modules/subform_element/subform_element.module: 211	
][,   

_subform_element_add_name_prefix_recursive	/home/mykle/mun3/www/modules/subform_element/subform_element.module: 202	"image_node_form", Array
(
    [#after_build_done] => 1
)

_subform_element_add_name_prefix_recursive	/home/mykle/mun3/www/modules/subform_element/subform_element.module: 195	"image_node_form", ($form)

subform_element_separate_data	/home/mykle/mun3/www/includes/form.inc: 472	
"image_node_form", ($form)

drupal_render_form	/home/mykle/mun3/www/modules/subform_element/subform_element.module: 105	
"image_node_form", ($form)

theme_subform_element
($form)

call_user_func_array	/home/mykle/mun3/www/includes/theme.inc: 170	
"theme_subform_element", ($form)

theme	/home/mykle/mun3/www/includes/common.inc: 2176	
"subform_element", ($form)

drupal_render	/home/mykle/mun3/www/includes/common.inc: 2166
($form)

drupal_render	/home/mykle/mun3/www/includes/common.inc: 2166
($form)

drupal_render	/home/mykle/mun3/www/includes/common.inc: 2166
($form)

drupal_render	/home/mykle/mun3/www/modules/node/node.module: 2176
($form)

theme_node_form
($form)

call_user_func_array	/home/mykle/mun3/www/includes/theme.inc: 170	
"theme_node_form", ($form)

theme	/home/mykle/mun3/www/includes/common.inc: 2157	
"node_form", ($form)

drupal_render	/home/mykle/mun3/www/includes/form.inc: 477
($form)

drupal_render_form	/home/mykle/mun3/www/includes/form.inc: 98	
"story_node_form", ($form)

drupal_get_form	/home/mykle/mun3/www/modules/node/node.module: 2204	
"story_node_form", Array
(
    [uid] => 1
    [name] => admin
    [type] => story
)

node_add		
"story"

call_user_func_array	/home/mykle/mun3/www/includes/menu.inc: 418	
"node_add", Array
(
    [0] => story
)

menu_execute_active_handler	/home/mykle/mun3/www/index.php: 15

--------
this is with an AddNode CCK field added to the Story type, pointing to an Image type provided by the Image module.

mykle’s picture

Project: Addnode » Image
Component: Code » image.module

This only happens when one of the types of the Node Reference is an Image object from the Image module.

subform_element is being handed a garbled form array there. $form[thumbnail] is a child with only one property: #after_build_done = true.

Perhaps this property is supposed to be set on $form[images][thumbnail] instead?

This raises a bug classification question: is the bug in image? addnode? subform element? I don't know. I'm setting it to image for now.

sun’s picture

Status: Active » Closed (won't fix)

Sorry, I have no idea either. Please have a look at the issue queue - Image maintainers are buried already.