Fernan Aguero wrote:
[ or perhaps 'is it possible to clone a resultset?' ]

Hi!

I'm building a form whose elements are items taken from the
db.  And I need these items to show up in different elements
(fieldsets) of the form. More or less something like this:

With items similar to:
 'checkbox' - Item 1
 'checkbox' - Item 2
 'checkbox' - Item 3

with parts that belong to:
 'checkbox' - Item 1
 'checkbox' - Item 2
 'checkbox' - Item 3


In my controller:
my $rs = $model->search( ... );
$c->stash->{items} = $rs;

In my template (TT):
<form ...>
<fieldset>
[% WHILE ( it = items.next() ) -%]
<input ... > [% it.name -%]
[% END -%]
</fieldset>

<fieldset>
[% WHILE ( it = items.next() ) -%]
<input ... > [% it.name -%]
[% END -%]
</fieldset>
</form>

The problem is that the resultset is empty when I try to
iterate over it the second time.
So far the only way I've found to make this work is
to do N separate searches, fill N stash elements, et cetera
$rs1 = $model->search( ... ); $c->stash->{rs1} = $rs1;
$rs2 = $model->search( ... ); $c->stash->{rs2} = $rs2;
...

[% WHILE ( it = rs1.next() ) -%] ...
[% WHILE ( it = rs2.next() ) -%] ...

Is there any other way to do this? Is it possible to clone a
resultset?

Thanks,

Fernan


_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

1) WRONG MAILING LIST
2) RTFM
3) rs.reset.

_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to