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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Passing Parameters to FormAction


5 Posts   522 Views


7 November 2012 at 2:01am Community Member, 66 Posts


I'm using SilverStripe 2.4.7 and I followed this [url=]tutorial[/url]. It worked brilliantly but the next thing I want to do is pass some parameters into the doAction method. I'm having trouble finding any info on how this could be done. Sorry if this is a really obvious question. I'm stumped though. I assume I'll need to include and extra argument in

$Action = new FormAction(
"Do something different"

I'd appreciate any guidance.


7 November 2012 at 2:07am (Last edited: 7 November 2012 2:07am), Forum Moderator, 1796 Posts

What kind of parameter would you need to pass?

As an alternative I use what I call "onAfterWrite hack" (matches with "adding-a-cms-action-the-slightly-hacky-way")

put a check box on the DataObject, in the onAfterWrte determine if that is checked if it is do some action and then set it to unchecked and call write again. yes... hacky, hacky, hack-hack but it only wastes CPU/disk when saving and performing the your "action" and you can add anything you like to the DataObject or directly to the form that will be passed in for use with your "action"


7 November 2012 at 2:44am Community Member, 66 Posts

Thanks for your reply. I had considered the onAfterWrite method but don't actually want to write anything.

I'll give you some background to help explain. Basically, I am integrating urbanairship and I have it sending out push notifications with hard coded data but I want the user to be able to insert a message into a textfield and that to be sent to the Urban Airship method.


7 November 2012 at 3:58pm Forum Moderator, 1796 Posts

Ok well the onAfterWrite hack seems fine to me for your purpose - much more work to put get it into a form action (that it is not designed for) so I can help no further - best of luck


7 November 2012 at 9:52pm Community Member, 66 Posts

Your advice is much appreciated. Thanks. :)