Drupal drupal_get_form() Array Elements

mrroy69
mrroy69 used Ask the Experts™
on
drupal_get_form('search_form') spits out the following multidimensional array... How can I get the values for

[build_id]  and [type]  (see bolded below)

Array ( [#action] => /search/user [#attributes] => Array ( [class] => Array ( [0] => search-form ) ) [module] => Array ( [#type] => value [#value] => [#input] => 1 [#after_build] => Array ( [0] => conditional_fields_element_after_build ) [#defaults_loaded] => 1 [#tree] => [#parents] => Array ( [0] => module ) [#array_parents] => Array ( [0] => module ) [#weight] => 0 [#processed] => [#required] => [#attributes] => Array ( ) [#title_display] => before [#id] => edit-module [#name] => module [#sorted] => 1 [#after_build_done] => 1 ) [basic] => Array ( [#type] => container [#attributes] => Array ( [class] => Array ( [0] => container-inline ) ) [keys] => Array ( [#type] => textfield [#title] => Enter your keywords [#default_value] => [#size] => 40 [#maxlength] => 255 [#input] => 1 [#autocomplete_path] => [#process] => Array ( [0] => form_process_autocomplete [1] => ajax_process_form ) [#theme] => textfield [#theme_wrappers] => Array ( [0] => form_element ) [#pre_render] => Array ( [0] => ctools_dependent_pre_render ) [#after_build] => Array ( [0] => conditional_fields_element_after_build ) [#defaults_loaded] => 1 [#tree] => [#parents] => Array ( [0] => keys ) [#array_parents] => Array ( [0] => basic [1] => keys ) [#weight] => 0 [#processed] => 1 [#required] => [#attributes] => Array ( ) [#title_display] => before [#id] => edit-keys [#name] => keys [#value] => [#autocomplete_input] => Array ( ) [#ajax_processed] => [#sorted] => 1 [#after_build_done] => 1 ) [processed_keys] => Array ( [#type] => value [#value] => [#input] => 1 [#after_build] => Array ( [0] => conditional_fields_element_after_build ) [#defaults_loaded] => 1 [#tree] => [#parents] => Array ( [0] => processed_keys ) [#array_parents] => Array ( [0] => basic [1] => processed_keys ) [#weight] => 0.001 [#processed] => [#required] => [#attributes] => Array ( ) [#title_display] => before [#id] => edit-processed-keys [#name] => processed_keys [#sorted] => 1 [#after_build_done] => 1 ) [submit] => Array ( [#type] => submit [#value] => Search [#input] => 1 [#name] => op [#button_type] => submit [#executes_submit_callback] => 1 [#limit_validation_errors] => [#process] => Array ( [0] => ajax_process_form ) [#theme_wrappers] => Array ( [0] => button ) [#after_build] => Array ( [0] => conditional_fields_element_after_build ) [#defaults_loaded] => 1 [#tree] => [#parents] => Array ( [0] => submit ) [#array_parents] => Array ( [0] => basic [1] => submit ) [#weight] => 0.002 [#processed] => 1 [#required] => [#attributes] => Array ( ) [#title_display] => before [#id] => edit-submit [#ajax_processed] => [#sorted] => 1 [#after_build_done] => 1 ) [#theme_wrappers] => Array ( [0] => container ) [#process] => Array ( [0] => form_process_container ) [#after_build] => Array ( [0] => conditional_fields_element_after_build ) [#defaults_loaded] => 1 [#tree] => [#parents] => Array ( [0] => basic ) [#array_parents] => Array ( [0] => basic ) [#weight] => 0.001 [#processed] => 1 [#required] => [#title_display] => before [#id] => edit-basic [#sorted] => 1 [#after_build_done] => 1 ) [#form_id] => search_form [#type] => form [#build_id] => form-WipUafnKd46_WuIzoMXmlm3xPAjxpMTpBxNDFyYYjI0 [form_build_id] => Array ( [#type] => hidden [#value] => form-WipUafnKd46_WuIzoMXmlm3xPAjxpMTpBxNDFyYYjI0 [#id] => form-WipUafnKd46_WuIzoMXmlm3xPAjxpMTpBxNDFyYYjI0 [#name] => form_build_id [#parents] => Array ( [0] => form_build_id ) [#input] => 1 [#process] => Array ( [0] => ajax_process_form ) [#theme] => hidden [#after_build] => Array ( [0] => conditional_fields_element_after_build ) [#defaults_loaded] => 1 [#tree] => [#array_parents] => Array ( [0] => form_build_id ) [#weight] => 0.002 [#processed] => 1 [#required] => [#attributes] => Array ( ) [#title_display] => before [#ajax_processed] => [#sorted] => 1 [#after_build_done] => 1 ) [#token] => search_form [form_token] => Array ( [#id] => edit-search-form-form-token [#type] => token [#default_value] => Nhp3zHW_KBFtqgxWcyk4FnLJh_9oyOlrTs3vF18QInw [#parents] => Array ( [0] => form_token ) [#input] => 1 [#theme] => hidden [#after_build] => Array ( [0] => conditional_fields_element_after_build ) [#defaults_loaded] => 1 [#tree] => [#array_parents] => Array ( [0] => form_token ) [#weight] => 0.003 [#processed] => [#required] => [#attributes] => Array ( ) [#title_display] => before [#name] => form_token [#value] => Nhp3zHW_KBFtqgxWcyk4FnLJh_9oyOlrTs3vF18QInw [#sorted] => 1 [#after_build_done] => 1 ) [form_id] => Array ( [#type] => hidden [#value] => search_form [#id] => edit-search-form [#parents] => Array ( [0] => form_id ) [#input] => 1 [#process] => Array ( [0] => ajax_process_form ) [#theme] => hidden [#after_build] => Array ( [0] => conditional_fields_element_after_build ) [#defaults_loaded] => 1 [#tree] => [#array_parents] => Array ( [0] => form_id ) [#weight] => 0.004 [#processed] => 1 [#required] => [#attributes] => Array ( ) [#title_display] => before [#name] => form_id [#ajax_processed] => [#sorted] => 1 [#after_build_done] => 1 ) [#id] => search-form [#method] => post [#theme_wrappers] => Array ( [0] => form ) [#after_build] => Array ( [0] => conditional_fields_element_after_build ) [#tree] => [#parents] => Array ( ) [#validate] => Array ( [0] => search_form_validate ) [#submit] => Array ( [0] => search_form_submit ) [#theme] => Array ( [0] => search_form ) [#processed] => [#defaults_loaded] => 1 [#required] => [#title_display] => before [#array_parents] => Array ( ) [#sorted] => 1 [#after_build_done] => 1 [#attached] => Array ( [js] => Array ( [0] => Array ( [type] => setting [data] => Array ( [urlIsAjaxTrusted] => Array ( [/search/user] => 1 ) ) ) ) ) )
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016

Commented:
Please use PHP var_export() then copy the resulting data.  Please paste the copied data into the code snippet here, so we have an executable code representation of the information and can see the data structure.  Then we can give you a good answer, including a tested and working code example.
Drupal Developer and Consultant
Commented:
Do you simply want to get these values into some variables? If so, this is what you need:
$form = drupal_get_form('search_form');
$type = $form['#type'];
$build_id = $form['#build_id'];

Open in new window

Author

Commented:
As usual...You know how to gt it done...Boom!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial