Basic help needed to add custom fields to event

After two days of looking for the answer I’m still stumped.

I am using XML as the data store and have added a few extra fields which are displaying in lightbox OK. They are not being either saved or retrieved from the XML file though and this suggested there was something else that needed modifying.

I have seen mention of scheduler admin but I can’t find it anywhere.

Can someone please point me in the right direction to get things working?

Thanks
Penfound

Hello Penfound,

we need more information to help you.

Which connector are you using (if you’re using one)?
If possible post your client- and serverside initialization code.

Sincerely,

Loewi

Sorry, I did mean to but forgot. Here is my code…

<!doctype html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>My Calendar</title>
</head>
<script src="dhtmlxscheduler_serialize.js" type="text/javascript" charset="utf-8"></script>
<script src="dhtmlxscheduler.js" type="text/javascript" charset="utf-8"></script>
<script src="dhtmlxscheduler_year_view.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="css/dhtmlxscheduler.css" type="text/css" title="no title" charset="utf-8">


<style type="text/css" media="screen">
    html, body {
        margin: 0px;
        padding: 0px;
        height: 100%;
        overflow: hidden;
    }

    .dhx_cal_navline input {
        width: 80px;
        position: absolute;
        top: 1px;
        font-family: Tahoma;
        font-weight: 100;
    }
</style>


<script type="text/javascript" charset="utf-8">
    function init() {
        //VARIABLES
        var format = scheduler.date.date_to_str("%H:%i");
        var step = 30;
        var alert_opts = [
            { key: 1, label: 'Graham' },
            { key: 2, label: 'Karen' },
            { key: 3, label: 'James' }
        ];
        var cat_opts = [
            { key: 1, label: 'Early Work' },
            { key: 2, label: 'Anytime Work' },
            { key: 3, label: 'Teachng' },
            { key: 4, label: 'Holiday' },
            { key: 5, label: 'Medical' },
            { key: 6, label: 'Westcountry' },
            { key: 7, label: 'Other 1' },
            { key: 8, label: 'Other 2' }
        ];

        //CONFIG
        scheduler.config.xml_date = "%Y-%m-%d %H:%i";
        scheduler.config.prevent_cache = true;
        scheduler.locale.labels.year_tab = "Year";
        scheduler.config.first_hour = 7;
        scheduler.config.last_hour = 20;
        scheduler.config.lightbox.sections = [
            { name: "Person", height: 30, map_to: "person", type: "select", options: alert_opts },
            { name: "Category", height: 30, map_to: "category", type: "select", options: cat_opts },
            { name: "description", height: 50, map_to: "text", type: "textarea", focus: true },
            { name: "time", height: 72, type: "time", map_to: "auto" }
        ]
        scheduler.config.event_duration = 30;
        scheduler.config.auto_end_date = true;

      

        //XY SECTION
        scheduler.xy.margin_top = 30;

        //VARIABLES
        var format = scheduler.date.date_to_str("%H:%i");
        var step = 30;
        var alert_opts = [
            { key: 1, label: 'Graham' },
            { key: 2, label: 'Karen' },
            { key: 3, label: 'James' }
        ];
        var cat_opts = [
            { key: 1, label: 'Early Work' },
            { key: 2, label: 'Anytime Work' },
            { key: 3, label: 'Teachng' },
            { key: 4, label: 'Holiday' },
            { key: 5, label: 'Medical' },
            { key: 6, label: 'Westcountry' },
            { key: 7, label: 'Other 1' },
            { key: 8, label: 'Other 2' }
        ];

        //LABELS
        scheduler.locale.labels.section_select = 'Person';
        scheduler.locale.labels.section_select = 'Category';

        //TEMPLLATES
        scheduler.templates.hour_scale = function (date) {
            html = "";
            for (var i = 0; i < 60 / step; i++) {
                html += "<div style='height:21px;line-height:21px;'>" + format(date) + "</div>";
                date = scheduler.date.add(date, step, "minute");
            }
            return html;
        }

        //INITIALIZATION
        scheduler.init('scheduler_here', new Date(), "month");
        scheduler.load("data/data.xml");


        function show() {
            alert(scheduler.toXML());
        }
        function save() {
            var form = document.forms[0];
            form.action = "data/xml_writer.php";
            form.elements.data.value = scheduler.toXML();
            form.submit();
        }
        function download() {
            var form = document.forms[0];
            form.action = "data/xml_download.php";
            form.elements.data.value = scheduler.toXML();
            form.submit();
        }
    }
</script>

<body onload="init();">
    <div style='height:20px; padding:5px 10px;'>
        <input type="button" name="download" value="Download" onclick="download()" style="right:500px;" />
        <input type="button" name="show" value="Show" onclick="show()" style="right:400px;" />
        <input type="button" name="save" value="Save" onclick="save()" style="right:300px;" />
    </div>
    <form action="../php/xml_writer.php" method="post" target="hidden_frame" accept-charset="utf-8">
        <input type="hidden" name="data" value="" id="data">
    </form>
    <iframe src='about:blank' frameborder="0" style="width:0px; height:0px;" id="hidden_frame" name="hidden_frame"></iframe>
    <div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
        <div class="dhx_cal_navline">
            <div class="dhx_cal_prev_button">&nbsp;</div>
            <div class="dhx_cal_next_button">&nbsp;</div>
            <div class="dhx_cal_today_button"></div>
            <div class="dhx_cal_date"></div>
            <div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
            <div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
            <div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
            <div class="dhx_cal_tab" name="year_tab" style="right:40px;"></div>
       </div>
        <div class="dhx_cal_header">
        </div>
        <div class="dhx_cal_data">
        </div>
    </div>
</body>

Server side

<?php
if(empty($_POST['data'])) {
	echo "why";
	exit;
}

$filename = "data.xml";

header("Cache-Control: ");
header("Content-type: text/plain");
header('Content-Disposition: attachment; filename="'.$filename.'"');

echo $_POST['data'];

?>

<?php
file_put_contents("data.xml",$_POST["data"]);
header("Location:data/dummy.html");
?

Both php files are located in the same folder as the data.xml file

I’m not using a connector - I think.

Configuration looks valid.
Please try to change data loading command like next ( to be sure that file is not cached )

scheduler.load("data/data.xml?uid="+(new Date()).valueOf());

If problem still occurs then please share content of data.xml

You should move your show(), save() and download() functions out of your init() function.
And include dhtmlxscheduler_serialize.js after dhtmlxscheduler.js.

Stanislav -
I did and also discovered an error in the XML file

Loewi - did what you suggested.

Thanks to both of you that problem is now solved.
I think when my calendar is complete I might post the code up here to help others master this brilliant code.