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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Passing Parameters to FormAction


Go to End


5 Posts   943 Views

Avatar
Stef87

Community Member, 66 Posts

7 November 2012 at 2:01am

Hi

I'm using SilverStripe 2.4.7 and I followed this tutorial. 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(
           "doAction",
           "Do something different"
        );

I'd appreciate any guidance.
Thanks

Avatar
swaiba

Forum Moderator, 1899 Posts

7 November 2012 at 2:07am

Edited: 07/11/2012 2:07am

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"

Avatar
Stef87

Community Member, 66 Posts

7 November 2012 at 2:44am

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.

Avatar
swaiba

Forum Moderator, 1899 Posts

7 November 2012 at 3:58pm

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

Avatar
Stef87

Community Member, 66 Posts

7 November 2012 at 9:52pm

Your advice is much appreciated. Thanks. :)