Hello,

I am dynamically creating a hierarchical select form using the same form function, but on call, it changes the vocab id and labels.

Here is my code for the form:

function custom_search_form($form, $vid, $labels) {
	$form = array();

	$form['hs_select_powerstar'] = array(
		'#type' => 'hierarchical_select',
		'#config' => array(
			'module' => 'hs_taxonomy',
			'params' => array(
				'vid' => $vid,
			),
			'save_lineage' => 1,
			'enforce_deepest' => 0,
			'entity_count' => 0,
			'level_labels' => array(
				'status' => 1,
				'labels' => $labels
			),

			'editability' => array(
				'status'=>0,
			),
			'resizable' => 0,
			'#required' => TRUE,
		),

	);

	$form['save'] = array(
		'#type' => 'submit',
		'#value' => t('Search'),
	);
	
	return $form;
}

Here is my form call:



	$vocabs = taxonomy_get_vocabularies(NULL);
	
	unset($vocabs[1]); // removing Acidfree Gallery Vocab
	unset($vocabs[2]); // removing Image Gallery Vocab

	/**
	Setting level labels for specific vocab ids
	*/

	// 5 is cars
	$labels[5][] = t("Choose a make");
	$labels[5][] = t("Choose a year");
	$labels[5][] = t("Choose a model");
	$labels[5][] = t("Choose an engine");
	
	// 3 is motorcycles
	$labels[3][] = t("Choose a make");
	$labels[3][] = t("Choose a year / model / engine");
	
	$x = 0;
	foreach($vocabs as $vocab_obj)
	{
		print drupal_get_form('custom_search_form', $vocab_obj->vid, $labels[$vocab_obj->vid]);
		$form_js[$vocab_obj->vid] = $x; $x++; // figuring out which vocab IDs go with which printed forms so we can implement js display/hiding
		
		
	}

Depending on the weight of the vocabulary, whichever is the top vocabulary in weight, the form values get passed. But when I submit another form, where the weight of the vocabulary (or isn't the first form output), the values do not get passed and the form state looks like this:

Array
(
    [hs_select_powerstar] => Array
        (
            [#type] => hierarchical_select
            [#config] => Array
                (
                    [module] => hs_taxonomy
                    [params] => Array
                        (
                            [vid] => 5
                        )

                    [save_lineage] => 1
                    [enforce_deepest] => 0
                    [entity_count] => 0
                    [level_labels] => Array
                        (
                            [status] => 1
                            [labels] => Array
                                (
                                    [0] => Choose a make
                                    [1] => Choose a year
                                    [2] => Choose a model
                                    [3] => Choose an engine
                                )

                        )

                    [editability] => Array
                        (
                            [status] => 0
                        )

                    [resizable] => 0
                    [#required] => 1
                )

        )

    [save] => Array
        (
            [#type] => submit
            [#value] => Search
        )

    [values] => Array
        (
            [hs_select_powerstar] => 
            [op] => Search
            [save] => Search
            [form_build_id] => form-36ec90920c05337e38fa6f82f3c5b698
            [form_token] => 21b1cd4b031c6a24f7cc21a9976f1064
            [form_id] => custom_search_form
            [hs_form_build_id] => hs_form_6629439ac2a6068b62f9b418a4088ee7
        )

    [submitted] => 1
    [clicked_button] => Array
        (
            [#type] => submit
            [#value] => Search
            [#post] => Array
                (
                    [hs_select_powerstar] => Array
                        (
                            [hsid] => 65
                            [hierarchical_select] => Array
                                (
                                    [selects] => Array
                                        (
                                            [0] => 158
                                            [1] => 164
                                        )

                                )

                        )

                    [op] => Search
                    [form_build_id] => form-e70b106e78cd582d4064c4b93c6a2b68
                    [form_token] => 21b1cd4b031c6a24f7cc21a9976f1064
                    [form_id] => custom_search_form
                    [hs_form_build_id] => hs_form_6629439ac2a6068b62f9b418a4088ee7
                )

            [#programmed] => 
            [#tree] => 
            [#parents] => Array
                (
                    [0] => save
                )

            [#array_parents] => Array
                (
                    [0] => save
                )

            [#weight] => 0.001
            [#processed] => 
            [#description] => 
            [#attributes] => Array
                (
                )

            [#required] => 
            [#input] => 1
            [#name] => op
            [#button_type] => submit
            [#executes_submit_callback] => 1
            [#process] => Array
                (
                    [0] => form_expand_ahah
                )

            [#id] => edit-save
        )

    [hs_form_build_id] => hs_form_6629439ac2a6068b62f9b418a4088ee7
    [redirect] => 
)

Note, the labels in the form state above are not the labels for the form I submitted from.

Thank you for your time!

Hilyin

Comments

wim leers’s picture

Assigned: Unassigned » wim leers
Category: bug » support
Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

Could you please make a screencast of the problem being reproduced. That makes it easier for me to understand the problem. Thanks!

P.S.: don't have any screencast software yet? On Windows and Mac OS X, you can use the free Jing.

wim leers’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Closing due to lack of response. Feel free to reopen when you've gathered the requested information.