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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

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

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

FormAction display query

Go to End

3 Posts   1362 Views


Community Member, 6 Posts

25 September 2008 at 2:22pm

How to use FormAction to display query from DataObject?


Forum Moderator, 5523 Posts

25 September 2008 at 4:42pm

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.


Community Member, 6 Posts

25 September 2008 at 10:00pm

Edited: 25/09/2008 10:01pm

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.