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]