[Html-widget] latest formfu developments - constraints and L10N
Carl Franks
fireartist at gmail.com
Tue Feb 27 17:17:30 GMT 2007
On 26/02/07, Mario Minati <mario at minati.de> wrote:
> mk_output_accessors in HTML::FormFu::Accessor:
> my $sub = sub {
> my $self = shift;
> if (@_) {
> $self->{$name} =
> ( @_ == 1 )
> ? output_value( $_[0] )
> : [ map { output_value( $_[0] ) } @_ ];
> return $self;
> }
> return $self->{$name};
> };
>
> In my opinion it should be
> map { output_value( $_ ) } @_
> instead of
> map { output_value( $_[0] ) } @_
You're right.
I've actually changed it to just:
if (@_) {
$self->{$name} = output_value( $_[0] );
return $self;
}
As passing multiple values would probably just cause TT to die anyway.
> I just had another idea.
> Would it be comfortable for the user if we could provide an extra
> message for constraints (maybe also filters) which is show like a
> comment. E. g. we provide a message like 'This field is required.' right
> away, instead of complaining afterwards, that we didn't get enough data.
> An alternativ would be to put an additional class in the container like
> 'constraint_required filter_whitespace', that would give the opportunity
> to do some color or icon coding in css.
I'd thought of adding constraints as classnames, but it unfortunately
doesn't buy much, as IE doesn't support the content{} property (and it
can't contain html anyway).
I wonder whether this belongs in the 'field' template?
[% IF self.has_xml_attribute( 'class', 'constraint_required' ) %]
<b>This field is required</b>
[% END %]
(the has_xml_attribute() method isn't currently exported to TT, but could be)
Carl
More information about the Html-widget
mailing list