Skip Menu |

This queue is for tickets about the HTML-Widget CPAN distribution.

Report information
The Basics
Id: 20782
Status: resolved
Priority: 0/
Queue: HTML-Widget

People
Owner: Nobody in particular
Requestors: attn.steven.kuo [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Fwd: Creating disabled Textfields?
Date: Mon, 31 Jul 2006 18:25:15 -0700
To: bug-HTML-Widget [...] rt.cpan.org
From: "Steven Kuo" <attn.steven.kuo [...] gmail.com>
I'll leave it to you to decide whether this is an enhancement request or bug. I wanted to create a disabled Textfield. Although not documented, this procedure is one that I thought would work from my brief peek into the source code -- I tried using the attributes method in HTML::Widget::Accessor: $w = HTML::Widget->new; $w->element(q{Textfield}, q{foo}) ->size(20) ->value(20) ->attributes({ disabled => q{disabled}}); print $w->process; <form action="/" id="widget" method="post"><fieldset><input class="textfield" disabled="disabled" id="widget_foo" name="foo" type="text" value="20" /></fieldset></form> Note, however, that the ->size method call doesn't work in conjunction with ->attributes. I ended up using ->attributes( { disabled => 'disabled', size => 20 } ) and discarding the call to ->size(20) Other details: $ perl -v This is perl, v5.8.7 built for i686-linux $ uname -a Linux timbre.nsc.com 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:50:31 EST 2004 i686 athlon i386 GNU/Linux Version 1.07 of HTML::Widget -- Regards, Steven
I've updated the documentation to make the behaviour clearer. The prefered method of setting attributes is $e->attributes->{disabled} = 'disabled'; rather than $e->attributes( { disabled => 'disabled' } ); This is because the the second method overwrites the existing attributes hash-ref, which is where 'size' is stored. The svn version contains the updated documentation http://oook.de/svn/trunk/HTML-Widget/ This will be included in release 1.09 Thanks, Carl
FYI, the behaviour has been changed so that passing a hashref doesn't wipe out the present attributes, but instead is added to them. $w->attributes( { foo => 'bar' } ); You may also just pass a list, instead of a hashref. $w->attributes( foo => 'bar' ); The return value is now the object reference, rather than the attributes hashref, so that method-chaining now works. This will still work $w->attributes->{foo} = 'bar'; because as a special-case, if no arguments are passed, the attributes hashref is returned. To empty the attributes hash, this will no longer work $w->attributes({}) use this instead %{ $w->attributes } = (); This has been implemented in the subversion repository (revision 5041) http://dev.catalystframework.org/repos/Catalyst/trunk/HTML-Widget and will be included in v1.10 when that's released.