[Catalyst] More on HTML::Widget

Sebastian Riedel sri at oook.de
Tue Jan 17 05:15:05 CET 2006


17.01.2006 04:35 Allen S. Rout:

>
> 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?

Yes, this is a bit tricky because of the embedding features, for now  
the external reference keeping you used above is the preferred way.

--
sebastian




More information about the Catalyst mailing list