2011 Posts in 1436 Topics by 620 members
|Go to End|
19 May 2011 at 6:26am
I have a form consisting of several dropdowns which allows users to filter a list of dataobjects (habits) that they want to see by various fields (deadline, assigned staffmember, priority). This works okay in the page.
The form's action is a function that uses the dropdown selections to create a filter statement for a dataobject::get. So far so good - I can see from my debug statements that the appropriate data object set is got.
I use a foreach loop to iterate over this set, adding some additional bits to each record via an array which seems to work okay. This is then written back into a data object set to be returned and displayed (on the same page as the original form). But I get an error:
'getviewer' does not exist on 'DataObjectSet'
Can anyone help me out with this? Although I have other forms doing a similar thing, I cannot get this to display the list of data objects I am returning. My code is here: http://www.sspaste.com/paste/show/4dd4134046e3c
As always any help much appreciated.
19 May 2011 at 1:08pm
As I explained on the IRC channel, getViewer is on the controller. You're trying to render a set as a page, to which it cannot do. You need to return a controller, which is usually $this.
In shorthand you can simply return an array to customise the template variables available to SSViewer on this controller, so you'll just need to encapsulate your DataObjectSet as such:
In your templates you can use $habitFilterForm to render the form, then <% control HabitSet %> to process the results.
You can just do this in the plain template (as HabitSet won't exist on normal render and be ignored), or you can create a template WhateverYourClassNameIs_filterhabits.ss (ClassName_action.ss) if you want to jazz things up once you have some results.
|Go to Top|