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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Date field wont save!


Reply

2 Posts   975 Views

Avatar
vegetav

23 June 2010 at 9:44pm Community Member, 23 Posts

I'm trying to make simple use of the DataObjectManager, I need Date, Title, and a PDF file upload. I've got it working apart from everytime I save, it doesn't save the date, only the title. This is my code...

PdfFile.php:

<?php

class PdfFile extends DataObject
{
   static $db = array (
      'Date' => 'Date',
      'Title' => 'Text'
   );

   static $has_one = array (
      'PDF' => 'File',
      'FilePage' => 'FilePage'
   );

   public function getCMSFields_forPopup()
   {
$dateField = new DateField('Date');
$dateField->setConfig('showcalendar', true);
      return new FieldSet(
         $dateField,
         new TextField('Title'),
         new FileField('PDF')
      );
   }
}

?>

FilePage.php:

<?php

class FilePage extends Page
{
static $db = array (
);

static $has_one = array (
);

static $has_many = array (
'PdfFiles' => 'PdfFile'
);

public function getCMSFields()
{
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.PDF", new DataObjectManager(
$this,
'PdfFiles',
'PdfFile',
array('Date'=>'Date', 'Title'=>'Title'),
'getCMSFields_forPopup'
));

return $f;
}
}

class FilePage_Controller extends Page_Controller {
}

?>

Any advice would be much appreciated!

Many thanks,
Vic

Avatar
UncleCheese

24 June 2010 at 2:46am 4085 Posts

Just use a DatePickerField.