I'm trying to get a custom DOM action working that sets one, and only one, of the objects in the DOM to 'current.' I feel like I've done everything correctly, and I'm not getting any errors, but the objects' property isn't changing. Any clue what I might be doing wrong? Here's the code:
In Location (the dataobject class):
public function customDOMActions() {
$title = $this->Type ? "Current" : "Past";
return new DataObjectManagerAction(
$title,
"InternationalPage_Controller/toggleCurrent",
"refresh"
);
}
public function toggleCurrent() {
if($this->getField('Type') == 'currLoc')
$this->setField('Type', 'pastLoc');
else
$this->setField('Type', 'currLoc');
$this->write();
}
And in InternationalPage (the parent page):
class InternationalPage_Controller extends Page_Controller {
static $url_handlers = array(
'toggleCurrent' => 'handleCurrent'
);
public function handleCurrent() {
$locations = DataObject::get('Location');
foreach($locations as $location) {
$location->toggleCurrent();
}
}
}