Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

Date field dissapears after publish


Reply


3 Posts   1558 Views

Avatar
Hello_electro

Community Member, 80 Posts

12 July 2009 at 5:35am

Edited: 12/07/2009 5:41am

Not sure if anyone has had this problem:

I created a Safety Tips section. In the admin side i have a date field. but when ever i enter the date and save/publish; if i exit that page on the admin side and come back to it the date field is empty. Any ideas why? does it have anything to do with the fact that i have date fields in other pages?

also: i notice that usingFF i got this error:

Error: Permission denied to get property HTMLDivElement.parentNode
Source File: http://site/jsparty/calendar/calendar.js
Line: 133

How do i get this removed? i do not get the error when i am on a blog entry which does not delete the calander date.

here is some code:

SafetyTipsHolder.php

<?php

class SafetyTipsPage extends RightNav {
static $db = array(
);
static $has_one = array(
"Photo" => "Image",
    "Date" => "SSDatetime",

);
   
function getCMSFields() {
$fields = parent::getCMSFields();
    $fields->addFieldToTab("Root.Content.Main", new PopupDateTimeField("Date"), "Content");
$fields->addFieldToTab("Root.Content.Images", new ImageField("Photo"));
   
return $fields;
}
}

class SafetyTipsPage_Controller extends RightNav_Controller {
   
}
?>

Please, please! any help??

Avatar
theAlien

Community Member, 131 Posts

13 July 2009 at 11:32am

Try putting "Date" => "SSDateTime" in static $db = array();

That should help.

$has_one is used for relating two database-tables to eachother (an item in one table has one relative in another table).
Unless you did some fancy things with DataObject, I guess you don't want that for you're Date-field.
With $db you'll store the value in the same table as all other Safety Tips-information.

This explains also the error: calendar.js is searching for a related table - which (off course) does not exist.

NB: The Photos are stored in the related Image-table so you should leave them in the $has_one array.

Avatar
Hello_electro

Community Member, 80 Posts

14 July 2009 at 11:00am

Thank so much! that was the issue. I appreciate you taking time to give some guidance.