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.

Form Questions

Add a function to FormAction


4 Posts   561 Views


21 March 2012 at 2:32am Community Member, 81 Posts

I'm trying to put a Excel - export function behind a CMS-button, but when hitting the button, the page moves to /admin/EditForm (wich gives a 404 error). I use the following code:

class ExcelExport extends Page {
function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab('Root.Content.Export', new FormAction('doExport', 'Export to excel'));
return $fields;


class ExcelExport_Controller extends Page_Controller {
public function doExport(){
FormResponse::status_message(sprintf('Export ok!' ),'good');
return FormResponse::respond();


21 March 2012 at 3:22am Forum Moderator, 1796 Posts

Hi quanto,

I'm curious why you're not using ModelAdmin and the the "Export CSV" that comes right out of the box - assuming that the information you wish to export is within DataObjects...

However you might investigate "allowed_actions" as if you don't add the required action there the page will most likely give you a 404.


21 March 2012 at 5:56am Community Member, 81 Posts

I need a Excel export class because the file uses 2 sheets.

Thanks, I will try the allowed_actions option.


22 March 2012 at 2:35am Community Member, 81 Posts

allowed_action didn't work. I see in the source the "Export to Excel" button is not been surrounded by <form>. How do I fix this? so something like this:

$fields->addFieldToTab('Root.Content.Export', new Form('doExport', 'Export to excel')); //but with a button...