Martin Bower wrote:
Below the data is passed and displayed ok, but when I submit the form,
the [% element %] is passed pack to my script as a scalar , with an
example value of "HASH(0x10a88f4)"
Am I able to pass back the hash ion the simplistic way ?
The reason for this, is that there are approx 50 fields inside the hash,
and I'd like the user to be able to edit 2 of them , before submitting
this data to a database.
Regards
Martin
script
my %r = ( elem1 => 'one,
elem2 => 'two',
...
);
push(@elem_data,\%r);
Template
<form ...>
[% FOREACH element IN elem_data %]
<tr><td>[% element.elem1 %]</td>
<td>[% element.elem2 %]</td>
<td><input name="elem_data" value="[% element %]"></td>
</tr>
[% END %]
</form>
I don't think there is an easy way to do this currently, although something
like [% element.each.join(',') | html %] might work maybe. You should probably
urlencode it too, so things like line returns are escaped. You're probably
better off just creating your own serialize virtual method that uses base64,
though. Also, the each behavior is going to be changing in TT3, so I would be
aware of that.
You could also just use a foreach and make a bunch of hidden inputs. Or just
store the hash on the server and assign the form a unique id that would
associate it with the hash.
-- Josh
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates