Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Date field dissapears after publish

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1417 Views
  • Hello_electro
    Avatar
    Community Member
    80 Posts

    Date field dissapears after publish Link to this post

    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??

  • theAlien
    Avatar
    Community Member
    131 Posts

    Re: Date field dissapears after publish Link to this post

    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.

  • Hello_electro
    Avatar
    Community Member
    80 Posts

    Re: Date field dissapears after publish Link to this post

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

    1417 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.