Php 在DHTMLX中使用BeforeInsert并将变量传递给窗体

Php 在DHTMLX中使用BeforeInsert并将变量传递给窗体,php,dhtmlx,dhtmlx-scheduler,Php,Dhtmlx,Dhtmlx Scheduler,我有以下问题:我有一个调度程序,由不同的用户使用。当用户向调度器添加事件时,必须将包含其id的会话变量传递给处理器,并将其插入数据库 我的第一个问题是如何将会话变量绑定到使用scheduler.config.lightbox.sections创建的表单上: scheduler.config.lightbox.sections=[ {name:"Customer Code", height:21, map_to:"text", type:"textarea" , focus:f

我有以下问题:我有一个调度程序,由不同的用户使用。当用户向调度器添加事件时,必须将包含其id的会话变量传递给处理器,并将其插入数据库

我的第一个问题是如何将会话变量绑定到使用
scheduler.config.lightbox.sections创建的表单上:

  scheduler.config.lightbox.sections=[
        {name:"Customer Code", height:21, map_to:"text", type:"textarea" , focus:false},
    {name:"Photographer", height:21,  map_to:"pid", type:"select",
      options:scheduler.serverList("type")},
        {name:"time", height:72, type:"time", map_to:"auto"}
    ]
可以将会话变量绑定到它吗

我的第二个问题是如何在processor.php中获取会话变量? 如果我错了,请纠正我,但根据文档,会是这样的:

//... connect here
function myInsert($action){
        $new_value = rand(0,100);
        $action->set_value("name",$new_value);
}

$conn->event->attach("beforeInsert","myInsert");
// ...some code here
$conn->render_table("photographers_at_work", "id", "time, end_time, customer_code, pid"); 

您可以使用onEventCreated为新创建的事件分配默认值(如用户id):

scheduler.attachEvent("onEventCreated", function(id,e){
    var event = scheduler.getEvent(id);
    event.pid = userId;
});

此API事件在打开lightbox之前激发,因此lightbox将接收指定的值

至于后端-是的,类似的东西应该可以工作。几张纸条

  • $action->set_value-第一个参数是列名
  • 此列必须列在您提供给连接器的属性列中(即,如果您设置了渲染表参数中没有的列的值,连接器将忽略它)
  • 因此,应采取以下措施:

    //... connect here
    function myInsert($action){
            global $userId;
            $action->set_value("pid",$userId);// ! set value of "pid" column
    }
    
    $conn->event->attach("beforeInsert","myInsert");
    // ...some code here
    $conn->render_table("photographers_at_work", "id", "time, end_time, customer_code, pid");
    
    您可以启用连接器日志记录以查看连接器生成的实际sql请求: