There is a block created in views that displays the values of the taxonomy term fields. This block should be loaded when selecting a term from the select field in a custom form. Accordingly, the block needs to somehow pass the tid of the term selected in the form. The Select field in the form is formed as follows:

$form['rq_program'] = array(
       '#type' => 'select',
       '#title' => t('Program'),
       '#options' => GetProgramNameArray(), 
       '#required'=> TRUE,
       '#ajax' => array(
          'callback' => 'GetTermInfo', 
          'wrapper' => 'form-ajax-content',
          'method' => 'html',
          'effect' => 'fade',        

callback function:

function GetTermInfo($form, $form_state) {      
    $tid=$form_state['values']['rq_program']; //value from select
    $block = block_load('views', 'views_program_block');
    $content = _block_get_renderable_array(_block_render_blocks(array($block)));
    $output = drupal_render($content);
    return render($output);  

I can't understand how to pass $tid to the block, how to set up a context filter in this block to receive this $tid?

1 Answer 1


If the block you generated uses a contextual filter, maybe this could be the answer: https://drupal.stackexchange.com/a/205731/98697

  • I found an incredibly simple solution: views_embed_view('my_views', 'my_block', array($tid));
    – Anche
    May 31, 2021 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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