[Catalyst] More on HTML::Widget
Allen S. Rout
asr at ufl.edu
Tue Jan 17 04:35:03 CET 2006
In HTML::Widget, there does not appear to be an advertised way to
modify an Element once it is defined, short of keeping a list of
elements and carrying them around outside the object. For example,
my $form = new HTML::Widget;
$form->element( 'Textfield', 'name' )->label('Name')->size(30);
At this point I can no longer set the value of the 'name' field, I
think.
$form->element('name')->value("new val");, a plausible candidate for
that function, is of course wrong: it tries to define a new element of
type 'name'.
If element() took ($self,$name,$type), then it would be possible to
distinguish wether you were looking for an extant element rather or
defining a new one.
I could, of course, do something like
$fields = {};
$fields->{'name'} = $form->element(...);
but since I know that the same exact hash is present in
$form->{_elements}
it just irks me to carry it around on the outside. Of course, I don't
want to climb inside and violate the API.
Opinions?
- Allen S. Rout
More information about the Catalyst
mailing list