Get the display value of a Dropdown field in a logic hook

bsoremsugar —  December 4, 2012 — 6 Comments

Here’s a simple one, from a question I recently answered on the forums. If you have a Dropdown field, how can you get the display value for use in a logic hook? It’s a bit tricky, but all that’s needed is for you to reference the language pack strings and the vardef for the field like so…

And for MultiSelect fields, the same approach also works with a small tweak to decode the field and then leverage PHP 5.3 style closures to translate each value.

6 responses to Get the display value of a Dropdown field in a logic hook

  1. 

    You could also use translate function:

    $val = translate($bean->field_defs[$fieldname][‘options’], ”, $bean->$fieldname);

  2. 

    Hi John sir,

    I have problem of dropdown when i export , then got dropdwon Value instead of label . my export_query function is
    function create_export_query(&$order_by, &$where, $relate_link_join=”)
    {
    $custom_join = $this->custom_fields->getJOIN(true, true,$where);
    $query = “SELECT
    cases_cstm.reason_c as subject,
    cases_cstm.product_c as product,
    cases_cstm.complaintstatus_c as status,cases.date_entered as date_entered FROM cases_cstm”;
    $query.= ” LEFT JOIN cases “;
    $query.= “ON cases_cstm.id_c = cases.id “;
    if($where != “”)
    $query.= “where ($where)”;
    return $query;
    }

    please help me with a solution
    Thanks
    Anes

Trackbacks and Pingbacks:

  1. How to make dropdown field value show proper in csv file - January 2, 2013

    […] […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s