Skip to content

Instantly share code, notes, and snippets.

@ss23
Created June 26, 2013 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ss23/5864262 to your computer and use it in GitHub Desktop.
Save ss23/5864262 to your computer and use it in GitHub Desktop.
<?php
public function populateDefaults() {
parent::populateDefaults();
if(!isset($this->Date) || $this->Date === null) {
$this->Date = SS_Datetime::now()->Format('Y-m-d H:i:s');
}
}
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', $dateTimeField = new DatetimeField('Date'), 'Content');
$dateTimeField->getDateField()->setConfig('showcalendar', true);
$categories = NewsCategory::get()->sort('Title ASC');
if ($categories && $categories->exists()) {
$fields->addFieldToTab('Root.Main', new DropdownField('CategoryID', 'Category', $categories->map()), 'Content');
}
$fields->addFieldToTab('Root.Main', new TextareaField('Abstract'), 'Content');
return $fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment