Hi guys,
I'm trying to add a button in the CMS edit/amend page in ModelAdmin.
I have worked out how to add the button (code below)
This places a new button at the bottom of the CMS page beside the standard CMS Add/Delete buttons -- all good so far
The problem is that on clicking any of the CMS buttons on this page including the standard buttons SS flashes up a Forbidden message and does nothing else
Clearly I am missing something here, but I cannot for the life of me work out out what
Any help you can offer would be most welcome
Thanks in advance
Mike Armstrong
(Silvertoad Ltd)
the code so far
Quote.php
class Quote extends DataObject {
public function getCMSActions() {
$actions = parent::getCMSActions();
$bookAction = new FormAction ('doBookVehicle', 'Book Vehicle');
$bookAction->addExtraClass('ss-ui-action-constructive');
$actions->push($bookAction);
return $actions;
}
} // end class QuoteValidator
QuoteAdmin.php
class QuoteAdmin extends ModelAdmin {
public function getEditForm($id = null, $fields = null) {
$form = parent::getEditForm($id, $fields);
$listField = $form->Fields()->fieldByName($this->modelClass);
if ($gridField = $listField->getConfig()->getComponentByType('GridFieldDetailForm'))
$gridField->setItemRequestClass('QuoteFieldDetailForm_ItemRequest');
return $form;
}
} // end class QuoteAdmin
class QuoteFieldDetailForm_ItemRequest extends GridFieldDetailForm_ItemRequest {
public function ItemEditForm() {
$form = parent::ItemEditForm();
$formActions = $form->Actions();
if ($actions = $this->record->getCMSActions())
foreach ($actions as $action)
$formActions->push($action);
return $form;
}
public function doBookVehicle($data, $form) {
// do stuff here
}
} // end class QuoteFieldDetailForm_ItemRequest