1778 Posts in 581 Topics by 555 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 331 Views |
-
Add a function to FormAction

21 March 2012 at 2:32am
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();
} -
Re: Add a function to FormAction

21 March 2012 at 3:22am
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.
-
Re: Add a function to FormAction

21 March 2012 at 5:56am
I need a Excel export class because the file uses 2 sheets.
Thanks, I will try the allowed_actions option.
-
Re: Add a function to FormAction

22 March 2012 at 2:35am
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...
| 331 Views | ||
|
Page:
1
|
Go to Top |


