Problem with drop-down list

I have added a drop-down for a field “Event Type” on a Scheduler. The “event” table has an additional field “event_type_id”, and the source for the list of Event Types is a table “event_type”, which has an associated model “EventType”, and fields “id” and “name”.

scheduler.locale.labels.section_type = 'Type';
scheduler.config.lightbox.sections = [
{ name:"description", height:50, type:"textarea", map_to:"text", focus:true},
{ name:"type",height:21,map_to:"event_type_id",type:"select",options:scheduler.serverList("types")},
{ name:"time", height:72, type:"time", map_to:"auto"}  
];

In the server code, I have this:

$column_ids = 'date_start,date_end,text';
$strSQL = "SELECT  date_start,date_end,text,event_type_id FROM event WHERE _sys_user_id=$user_id"; //This SQL selects events for current logged-in user
$model = Event::model()->findAllBySql($strSQL);
$scheduler = new SchedulerConnector($model, "PHPYii");
$type_list = new OptionsConnector(EventType::model(), "PHPYii");
$type_list->render_table("event_type","id","id,name");
$scheduler->set_options("types",$type_list);
$scheduler->configure("-", "id", $column_ids);
$scheduler->render();

The drop-down is being populated with the correct number of items (there are 7 different Event Types), but the labels are all null, as in the screenshot below.

[i]
(By the way, the server code above successfully reads events, but to save back to the Db using DataProcessor I had to replace

$model = Event::model()->findAllBySql($strSQL);

with:

$model = Event::model()->findBySql($strSQL);

Also, if I add the event_type_id to the list of $column_ids, like this:

$column_ids = 'date_start,date_end,text,event_type_id';

…the save back to the Db fails:[/i]


Try to change

$type_list->render_table("event_type","id","id,name");

with

$type_list->render_table("event_type","id","id(value),name(label)");

Hi Stanislav

Actually, that was what I first tried (as per the guide), but if just gives a completely blank list as in the attached:


I see the problem.
Currently, when loading data through PHPYii driver, code takes attributes from model without renaming. The above proposed modification doesn’t work.

We will try to fix this functionality. For now, the only way to solve issue will be switching to native DB operations ( if you will use db connection objec and Mysql data adapter, the same code will provide valid list of options )

Probably you can extend your data model
if model will have “value” and “label” properties then connector will provide the valid list of options

OK - thanks Stanislav. I now have the lists populated correctly, using the mysql_connect() format.

How do I get the Scheduler to write the selected event_type_id back to the events table?

At the moment I am using:

{ name:"type",height:21,map_to:"event_type_id",type:"select",options:scheduler.serverList("types")},

but this doesn’t seem to work.

Ah - I see - need to use:

$scheduler = new SchedulerConnector($res);

and replace:

$scheduler->configure("-", "id", $column_ids);

with:

$scheduler->configure("event", "id", $column_ids);

Now it works!