So I've got a nice list of products in a tableselect element, like this:

$form['nodes'] = array(
  '#type' => 'tableselect',
  '#header' => $header,
  '#options' => $options,
  '#empty' => t('No content available.'),

I'm using EntityFieldQuery to make $options and each row is a "product", with a "product type" field which is a taxonomy term. But I want to sort the "product type" column by the taxonomy term rather than the tid (currently they aren't alphabetical and I intend to add more). This is what I've got now:

$header = array(
    'Name' => array(...
    'Product_type' => array(
        'data' => t('Product Type'),
        'specifier' => array(
    'Price' => array(...),

Is there a way to do this? I'm trying to avoid using "Views".

  • why dont you add the term itself instead of the id? – Mohammed Shameem Jan 21 '13 at 9:04
  • @MohammedShameem The "product" node links to the nid, not the term. Can I do that EFQ? – Coomie Jan 22 '13 at 0:44

Your Answer

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

Browse other questions tagged or ask your own question.