Re: inflating columns to objects
[prev]
[thread]
[next]
[Date index for 2004/10/26]
On Tue, 26 Oct 2004 17:41:56 +0100, Dave Howorth
<dhoworth@xxxxxxx.xxx.xx.xx> wrote:
> Drew Taylor wrote:
> > Would a <textarea> not suffice here? It does the wrapping for you
> > within the browser but will send it all back as a single string to the
> > server. Unfortunately I'm not familiar with asForm so I can't tell you
> > how to get a <textarea> versus an <input type="text">
>
> Hi Drew,
>
> My problem isn't whether it's a textarea or not. AsForm should make that
> decision. But in any case it's all living within the Maypole framework
> and I think providing an inflation method is what I should be doing. The
> problem is that the inflation class I wrote isn't working properly in
> conjunction with AsForm. I expect I've misunderstood what I have to do
> in writing such a class.
I'm a bit confused (I'm also not a current maypole user either so...).
But if the column is just text, and AsForm will decide what widget to
use, then why do you need to inflate it? Inflating is usually done
when you have an object you'd like to present in a special way (ie a
Date object should display in your chosen format). Are you saying you
want the text itself formatted into lines? If so, why not just let the
form widget handle it?
As for how to inflate something it's very simple:
MyClass->columns(Essential=>qw(...my_col...));
MyClass->has_a(my_col => MyInflator, inflate=>\&MyInflator::inflate);
# the subref can be located in any package - just use a fully
qualified function name
package MyInflator;
sub inflate {
my $value = shift;
# format it...
return $formatted;
}
Drew
--
----------------------------------------------------------------
Drew Taylor * Web development & consulting
Email: drew@xxxxxxxxxx.xxx * Site implementation & hosting
Web : www.drewtaylor.com * perl/mod_perl/DBI/mysql/postgres
----------------------------------------------------------------
|
(message missing)
|