How can i show every node title which is related to the taxonomy term in a form field? I work a little bit around and think i'm really close for a solution, but thats a little bit too tricky for me. I get one node title, but if i related 2 nodes to one term, i still get only one with an error message. I think i need to built an extra array, but I didn`t know how to handle it with the $link[$data->tid].

        $terms = taxonomy_get_tree('1', 0, NULL, TRUE);
        $image_style = 'medium';

        foreach ($terms as $data) {
          if(!empty($data->field_term_image['und'])) {
            $output[$data->tid] = '<img src="'.image_style_url($image_style ,$data->field_term_image['und'][0]['uri']).'" />'. $data->name;
          } else {
            $output[$data->tid] = $data->name;

          $term_nids = taxonomy_select_nodes($data->tid, FALSE);
          $nodes = node_load_multiple($term_nids);

          foreach($nodes as $node){
            $link[$data->tid] = $node->title;

        $form['step_1']['city_default'] = array(
          '#type' => 'radios',
          '#title' => t('Default category'),
          '#options' => $output,
          '#description' => t('The selected category will be shown by default on listing pages.'),

        foreach ($form['step_1']['city_default']['#options'] as $key => $city_text) {
          $form['step_1']['city_default'][$key]['#description'] = $link[$key];

Glad about every help.


You could do this with entity references and the views merge rows module.. An entity reference field to the taxonomy term and an entity reference view providing the term and all related nodes.. Here's a quick example I did up on a node add form. I can give more detail tomorrow if it's what you need.


|improve this answer|||||
  • Hi, Thanks for your replying. I found a solution with implode(), so i transform 1st the array to a string and after this I delete the array, I will post a clean script tomorrow, maybe then you can show me a better way for using the array in the form. – Bruno Mar 9 '16 at 1:03
  • Not up to speed yet with custom forms so wouldn't be any help. Good luck! – Niall Murphy Mar 9 '16 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.