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

Mario Minati mario at minati.de
Mon Feb 26 14:29:39 GMT 2007


Carl Franks schrieb:
> On 24/02/07, Mario Minati <mario at minati.de> wrote:
>> Carl Franks schrieb:
>> > I18N support has been added, with all error messages being moved out
>> > to the FormFu/I18N/en.pm package.
>> I discovered that and found a bug (probably).
>> When defining a constraint like this:
>> $form->constraint( Required => qw/shortname name/ )->message('mm -
>> Required. ');
>> It tries to get a translation for 'mm - Required. ', which of course is
>> not available.
>> So I think we need a way to bypass the I18N.
>
> Previously, the field 'label', 'comment' and 'value' accessors had
> *_xml() varients, for ensuring that the output isn't html-escaped.
> Last week as an experimental feature, I also added a *_loc() varient,
> as the means for passing a string which should be localised.
>
> I've now extended this to the constraints and errors, so they have
> message(), message_xml() and message_loc()
>
> I've described it as experimental, because I'm not sure yet if this is
> the best solution, so of course it may change.
Yes I saw that, but I have still a problem understanding the code:
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] ) } @_

Now my not yet localized message works 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.

The rest will be answered stepwise ;-)

Greets,
Mario



More information about the Html-widget mailing list