Can't set custom date attribute

Permalink 1 user found helpful
I'm trying to set up a start date and end date range. The start date gets set just fine, but I can't seem to get the end date value.

This is my saveData function in my controller:

private function saveData($p) {
      $blocks = $p->getBlocks('Main');
      foreach($blocks as $b) {
         $b->deleteBlock();
      }
      $bt = BlockType::getByHandle('content');
      $data = array('content' => $this->post('eventsBody'));
      $p->addBlock($bt, 'Main', $data);
      Loader::model("attribute/categories/collection");
      $cak2 = CollectionAttributeKey::getByHandle('events_thumbnail');
      $cak2->saveAttributeForm($p);
      $cak3 = CollectionAttributeKey::getByHandle('events_main_image');
      $cak3->saveAttributeForm($p);
      $cak4 = CollectionAttributeKey::getByHandle('prov');
      $cak4->saveAttributeForm($p);


And here's my code on the form that gets submitted:

$endDateValue = date("Y-m-d H:i:s",strtotime($c->getAttribute('events_end')));
<strong><?php echo $form->label('eventsEndDate', t('End Date'))?></strong>
<div><?php echo $df->datetime('eventsEndDate', $endDateValue)?></div>
<br/>


Any idea what I should be doing differently?

adamzwakk
 
adamzwakk replied on at Permalink Best Answer Reply
adamzwakk
I should note that doing this

$p->setAttribute('events_end', '2012-06-29 10:10:10');


in the saveData function sets that attribute, but I can't seem to get the values sent from the form.

Edit:

This seemed to work for me. Hope it helps someone.

$p->setAttribute('events_start', Loader::helper('form/date_time')->translate('eventsDate'));
$p->setAttribute('events_end', Loader::helper('form/date_time')->translate('eventsEndDate'));