[Html-widget] latest formfu developments - constraints and L10N

Mario Minati mario at minati.de
Wed Feb 28 00:20:00 GMT 2007


Carl Franks schrieb:
> 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.
Fine.
>
>> 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)
With this solution (classes for constraints gets set in the result 
function of field.pm) we can
provide some css coding, maybe bold names mean required.
Or we can adjust the field template the way you showed above to printout 
some text or even to generated some javascript constraint checking.
Or would you like to handle javascript constraints inside of FormFu?

Greets,
Mario



More information about the Html-widget mailing list