Jump to:

23451 Posts in 18899 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Passing Parameters to FormAction

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

Page: 1
Go to End
Author Topic: 508 Views
  • Stef87
    Avatar
    Community Member
    66 Posts

    Passing Parameters to FormAction Link to this post

    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

  • swaiba
    Avatar
    Forum Moderator
    1788 Posts

    Re: Passing Parameters to FormAction Link to this post

    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"

  • Stef87
    Avatar
    Community Member
    66 Posts

    Re: Passing Parameters to FormAction Link to this post

    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.

  • swaiba
    Avatar
    Forum Moderator
    1788 Posts

    Re: Passing Parameters to FormAction Link to this post

    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

  • Stef87
    Avatar
    Community Member
    66 Posts

    Re: Passing Parameters to FormAction Link to this post

    Your advice is much appreciated. Thanks.

    508 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.