I am trying to use this to create a "search" block of tax terms but I cant get the API to output anything when I run it through drupal_render_form(). I have the module installed and its working fine. When I add a new tax term, it does its fancy sliding stuff so I know the module is working. I installed the HS dev version which I think is HS 3. But the example API.txt seems to be written for HS2. What am I doing wrong in the code below? I would think that it would output a form with a submit button (which displays fine) along with an HS field of tax terms for Vid 2 but the only thing that shows up is the submit button.

//Implementation of hook block
function sharp_carsearch_block($op = 'list', $delta = 0, $edit = array()) 
{
  if ($op == 'list') 
  {
    $blocks[0] = array('info' => t('Car Search'),
      'weight' => 0, 'status' => 0, 'region' => 'right');
    return $blocks;
  }
   
   if ($op == 'view') 
   {
      if ($delta == 0) //Search Block
      {
         $block = array('subject' => t('Search Cars'),
         'content' => sharp_carsearch_search_block());
      }
    return $block;
  }
}

function sharp_carsearch_search_block()
{
    $form['select_some_term'] = array(
    '#type' => 'hierarchical_select',
    '#title' => t('Select the tag you wish to use.'),
    '#size' => 1,
    '#config' => array(
      'module' => 'taxonomy',
      'params' => array(
        'vid' => 2, //2 is the ID of the vocab I have assigned all the terms to.
      ),
      'save_lineage'    => 0,
      'enforce_deepest' => 0,
      'entity_count'    => 0,
      'level_labels' => array(
        'status' => 0,
        'labels' => array(
          0 => t('Main category'),
          1 => t('Subcategory'),
          2 => t('Third level category'),
        ),
      ),
      'dropbox' => array(
        'status'   => 0,
        'title'    => t('All selections'),
        'limit'    => 0,
        'reset_hs' => 1,
      ),
      'editability' => array(
        'status'           => 0,
        'item_types'       => array(),
        'allowed_levels'   => array(
          0 => 0,
          1 => 0,
          2 => 1,
        ),
        'allow_new_levels' => 0,
        'max_levels'       => 3,
      ),
      'animation_delay'    => 400,
      'exclusive_lineages' => array(),
      'render_flat_select' => 0,
      'resizable'          => 1,
    ),
    '#default_value' => '83',
  ); 

  
   $form['submit'] = array('#type' => 'submit', '#value' => t('test'));
  return drupal_render_form('carsearch', $form);
}

Comments

wim leers’s picture

Assigned: Unassigned » wim leers
Status: Active » Closed (duplicate)

Change 'taxonomy' to 'hs_taxonomy'. You're the third in 2 days, it seems many people are writing custom forms all of a sudden!

Another duplicate of http://drupal.org/node/314498.

drupaliedude’s picture

Yea I was digging through the issues here and I saw one about changing to hs_taxonomy. I did that and it didnt help any :( Is this an extra sub_module that needs to be installed? I thought it was this one, but maybe not?

Hierarchical Select Taxonomy 5.x-3.x-dev Use Hierarchical Select for Taxonomy.
Depends on: Hierarchical Select (enabled), Taxonomy (enabled)
Required by: Hierarchical Select Content Taxonomy (disabled), Hierarchical Select Taxonomy Subscriptions (disabled), Hierarchical Select Taxonomy Views (enabled)

This was the html output that was in the block. I can see the HS container but its blank :(

    <input type="submit" id="" value="test"  class="form-" />
<div class="form-item">
 <label>Select the tag you wish to use.: </label>
 <div  class=" hierarchical-select-wrapper hierarchical-select-level-labels-style-none" id="hierarchical-select--wrapper"></div>

junedkazi’s picture

I got away with that error by doing this

'params' => array(
        'vid' => 2, //2 is the ID of the vocab I have assigned all the terms to.
        'exclude_tid' => NULL,
        'root_term' => NULL,
      ),

Let me know if this works