Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 674549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:43:10+00:00 2026-05-14T00:43:10+00:00

I am a bit confused. I have created a simple form with a one

  • 0

I am a bit confused. I have created a simple form with a one text box and a submit button. Now I want to add a select/option dropdown box of taxonomy terms, using the taxonomy_get_vocabularies() function.

 $vocabularies = taxonomy_get_vocabularies('my_type'); 

My question is how do I get vocabulary list onto form “the Drupal way”. The way Drupal defines form seem quite rigid. Also how could I make this conditionl, say on existence of relevant taxonomy terms.

function my_form_name($form_state) {

// A Short question.
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Question'),
    '#default_value' => $node->title,
    '#required' => TRUE,
    '#weight' => 1,
    '#description' => t('A text box goes here '),   
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('submit'),
    '#weight' => 7,
  );

  return $form;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:43:11+00:00Added an answer on May 14, 2026 at 12:43 am

    I’m doing something similar in a custom form, and found it much easier to use taxonomy_get_tree, with the vocabulary code as the function’s argument. See below:

    //get the list of locations from taxonomy to use in the dropdown
    $dropdown_source = taxonomy_get_tree(2);
    $dropdown_array = array('0' => '--none--');
    foreach ($dropdown_source as $item) {
    $key = $item->tid;
    $value = $item->name;
    $dropdown_array[$key] = $value;
    }
    
    //location filter dropdown
    $form['filterset']['locationfilter'] = array(
      '#weight' => '1',
      '#key_type' => 'associative',
      '#multiple_toggle' => '1',
      '#type' => 'select',
      '#options' => $dropdown_array,
      '#title' => 'Filter by location',
    );
    
    unset($dropdown_array);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Bit confused here, I have an on-demand instance but do I get charged even
I'm a bit confused on this. I have a data table structured like this:
I am little bit confused about following problem & their solutions: i have 2
I have read few articles about table partioning but still I am bit confused
I'm getting a bit confused with UIViews recently, I have been using them fine
I have checkedout the docs on this but I am still a bit confused.
lately I got a bit confused concerning class-pathes in Manifest.mf-files. So what I want
I'm new to Git and a bit confused. I have a Master branch and
I got a bit confused: In production we have two processes communicating via shared
I have searched for this online, but am still a bit confused (as I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.