Saving Custom Fields To Database

Hi. I am really struggling with figuring out how to save custom fields back to the database using scheduler. I want to be able to add some custom fields to an event and then save those back to our database. I have been looking through the sample code but cannot figure it out. Hopefully someone can help. Here is the code I have so far:

Client Side Code:

[code]scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.init(‘scheduler_here’,null,“month”);

scheduler.form_blocks["my_editor"] = {
	render:function(sns) {
		return "<div class='dhx_cal_ltext' style='height:60px;'>Text&nbsp;<input type='text'><br/>Details&nbsp;<input type='text'></div>";
	},
	set_value:function(node, value, ev) {
		node.childNodes[1].value = value || "";
		node.childNodes[4].value = ev.details || "";
	},
	get_value:function(node, ev) {
		ev.details = node.childNodes[4].value;
		return node.childNodes[1].value;
	},
	focus:function(node) {
		var a = node.childNodes[1];
		a.select();
		a.focus();
	}
};
scheduler.config.lightbox.sections = [
	{ name:"description", height:200, map_to:"text", type:"my_editor" , focus:true},
	{ name:"time", height:72, type:"time", map_to:"auto"}
];

scheduler.load("/calendar_connector.php", function() {
	scheduler.showLightbox("1261150564");
});

var dp = new dataProcessor("/calendar_connector.php");
dp.init(scheduler);[/code]

Server Side Code:

[code]<?
require_once("…/calendar/codebase/connector/scheduler_connector.php");

$res=mysql_connect(“localhost”,“root”,"");
mysql_select_db(“ebiz”);

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

$conn->render_table("calendar_alerts","id","start_date,end_date,name,description");

?>[/code]

I would like the details input box to save into the description field in my database. What am I doing wrong?

Thanks,
Chris

Hello,

I would like the details input box to save into the description field in my database.
Control should be mapped to the related property of the event, it’s ‘map_to’ parameter of the configuration:scheduler.config.lightbox.sections = [ { name:"description", height:200, map_to:"description", type:"my_editor" , focus:true}

ev.details = node.childNodes[4].value; return node.childNodes[1].value;

That code sets value of childNodes[1] to text property, which will be saved on server side to “name” field and set values of childNodes[4] to “details”, which will not be saved at all. To fix it change code as

ev.description= node.childNodes[4].value;

Basically - 3 first field in connector config have hard mapping - they are start_date, end_date and text properties, all further properties in connector will be mapped by names, so if you want to update “description” property, you need to set ev.description

Thank you, that worked perfectly.