Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » FormAction display query

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1067 Views
  • hairiemx
    Avatar
    Community Member
    6 Posts

    FormAction display query Link to this post

    How to use FormAction to display query from DataObject?

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: FormAction display query Link to this post

    well formaction fires a function. You can see what function when you make your form

    new FormAction("doSomethingCool", "Do Something");

    and that will call a function called doSomethingCool which should be in the same file as that last piece of code (not the same function but in the same file). The doSomethingCool function recieves 2 pieces of data - the form and the data in the form so it would look something like

    function doSomethingCool($data, $form) {
    // the $data stores all the values in the form. You can access it like any array eg $data['SomeField'];
    }

    and in that function it will where you would do your DataObject query.

  • hairiemx
    Avatar
    Community Member
    6 Posts

    Re: FormAction display query Link to this post

    By referring to your example, from doSomethingCool, i don't know how to make the DataObject query available to the template.

    Currently what I did in the form action is, I cache the field value into Session and redirect to another page that will read the field value from session and do the query.

    What I'm trying to do is to create SearchForm (with multiple field) for specific DataObject and display the result of the search.

    1067 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.