OptionsConnector outputting data to XML but rendering null

I’ve used the below code to generate a select in my scheduler:

require_once("../codebase/connector/scheduler_connector.php");
 
$res=mysql_connect("localhost","pass","pass");
mysql_select_db("db_name");

$list = new OptionsConnector($res);
$list->render_table("tableA","firstName","clientId,firstName");

$conn = new SchedulerConnector($res);
$conn->enable_log("temp.log");

$conn->set_options("student", $list);
 
$conn->render_table("tableB","booking_id","start_date,end_date,text,coach,student");

and the client-side code as follows:

name: "student", height: 21, map_to: "student", type: "select", options:scheduler.serverList("student")

If I check the output for the connector.php in Chrome dev tools I can see it’s getting the correct data from my database. It’s not wrapped in CDATA, but it’s there, but the actual select is rendering the correct amount of items but the value and label are outputting ‘null’.

Would there be any particular reason for this?

Jon.

Hi,
connector and client-side scheduler expects options to have two mandatory fields - ‘label’ and ‘value’,
Since your table has different columns, you need to use aliases: $list->render_table("tableA","clientId","clientId(value),firstName(label)"); You can find the working example in connectors-php package
connector-php/samples/scheduler/03_connector_options.php

Awesome. That worked great. Thanks for your help.

Is it possible to concatenate values from a row? For example, if I wanted to use the first name and last name together as the label?

Sure, you can initialize connector with sql query which will select data in the desired format, something like following: $list->render_sql("select clientId as value,CONCAT(firstName, ' ', lastName) as label from tableA","value","value,label");

Perfect. Worked a treat, thank you so much. :slight_smile: