The following snippet is a piece of code I'm using to generate a form element to select terms from a vocabulary with multiselect turned on:

      $form['followup_assignment'] = taxonomy_form($followup_vid);
      $form['markup'] = array(
        '#value' => 'Just some markup',
      );
      $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Change'),
      );

      ...

      

A multiselect form element shows up fine on the page, but at the top of the page this form is on, I get this error in a message:
warning: implode() [function.implode]: Bad arguments. in /home/intranet/public_html/includes/form.inc on line 618.

When I comment out line 1 above, the error goes away. It seems to me like the culprit is the taxonomy_form function. Here is the output of the taxonomy_form function. Notice the [#options] property looks pretty unorthodox, but it still renders the form element OK. I find it hard to believe this code is broken, so I must be missing something obvious.

Array
(
    [#type] => select
    [#title] => Assignment
    [#default_value] => 0
    [#options] => Array
        (
            [0] => 
            [1] => stdClass Object
                (
                    [option] => Array
                        (
                            [220] => Andrew Jarvis
                        )

                )

            [2] => stdClass Object
                (
                    [option] => Array
                        (
                            [83] => Bill Bumpus
                        )

                )

        )

    [#description] => 
    [#multiple] => 1
    [#size] => 6
    [#weight] => -15
    [#theme] => taxonomy_term_select
)

Comments

nevets’s picture

Counting lines I think the line you are commenting out is

        '#value' => 'Just some markup',

If that is correct, try adding a '#type' => 'markup', to that form element.

Steve Dondley’s picture

No, sorry, the one above it, with taxonomy_form.

--
Prometheus

Steve Dondley’s picture

When I output the form in the $element in form.inc, I get the following. It seems it is missing the #parent property which is why it's throwing the error. What do I need to do to the form to get the #parent property into the form?

Array
(
    [#size] => 6
    [#weight] => -15
    [#theme] => taxonomy_term_select
    [#multiple] => 1
    [#description] => help
    [#title] => Assignment
    [#default_value] => Array
        (
            [0] => Bill Bumpus
        )

    [#options] => Array
        (
            [0] => 
            [1] => stdClass Object
                (
                    [option] => Array
                        (
                            [220] => Andrew Jarvis
                        )

                )

            [2] => stdClass Object
                (
                    [option] => Array
                        (
                            [83] => Bill Bumpus
                        )

                )

            [3] => stdClass Object
                (
                    [option] => Array
                        (
                            [194] => Joe Blow
                        )

                )

            [4] => stdClass Object
                (
                    [option] => Array
                        (
                            [82] => Morris Singer
                        )

                )

            [5] => stdClass Object
                (
                    [option] => Array
                        (
                            [84] => Steve Dondley
                        )

                )

        )

    [#type] => markup
    [#theme_used] => 1
    [#printed] => 1
)

--
Prometheus

[edit: added closing code tag: nevets]

Steve Dondley’s picture

Was not using drupal_get_form, I was using drupal_render_form(). Oops.

--
Prometheus