7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Help with Custom DOM Action
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 241 Views |
-
Help with Custom DOM Action

21 November 2011 at 1:36pm
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();
}
}
} -
Re: Help with Custom DOM Action

24 November 2011 at 4:20pm
You're going to need to provide more information. What is happening with the request? Are you sure it's hitting that controller? Can you put some output in that function and check the response?
---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com -
Re: Help with Custom DOM Action

24 November 2011 at 6:31pm
I'm getting a 200 from both the GET and the POST from the controller, so I think that part is working correctly, but I'll try to throw in some sort of output into the function when I get home to see if it really is.
Thanks for responding.
-
Re: Help with Custom DOM Action

28 November 2011 at 11:39am
Ok, now I'm getting a status:cancelled from the controller. I haven't been able to get the controller to return any output, so I'd guess I've broken something.
| 241 Views | ||
|
Page:
1
|
Go to Top |

