concatenating two fields to use as label in a drop down list

I’m trying to create a drop down list with labels created from a firstname and surname from a client table. In the examples I have found so far there are only those showing render_table mapping a single field to a label. I can see that you can use render_sql to select data and concatenate it but I can’t find how to bind it to a label

Hello,

SQL should be of help here:

SELECT item_id, CONCAT(item_nm, " ", item_cd) as label FROM countries

Best regards,
Ilya

Hi Ilya,
thank you very much for your response.
I did try something along those lines but I can’t find a way to bind the label to the select statement.

Here is the code that i’m using with my attempt to use sql as you direct commented out.

Connector code
$listclient = new OptionsConnector($res, $dbtype);
$listclient->render_table(“Contacts”, “ID”,“firstname(label),surname(value)”);
//$listclient->render_sql(“select ID as value, surname AS label from Contacts”);
//$listclient->render_sql(“select ID as value, CONCAT(firstname,surname) AS label from Contacts”);
$conn->set_options(“clients”, $listclient);

Lightbox code
scheduler.config.lightbox.sections = [
{name:“firstname”, height:21, map_to:“clientfullname”, type:“select”, options:scheduler.serverList(“clients”)},

I can only get the render_table function to work in this way.

Many thanks

John

Hello,

Try the following:

$listclient->render_sql("select ID as value, CONCAT(firstname,surname) AS label from Contacts","value","value,label");

or

$listclient->render_sql("select ID as value, CONCAT(firstname,surname) AS label from Contacts","ID","value,label");

Best regards,
Ilya

Hi Ilya - brilliant - thank you very much. worked a treat
Regards

John