[html-formfu] new 'force_default' attribute for elements

Carl Franks fireartist at gmail.com
Fri Sep 14 10:10:02 GMT 2007

Hi Mario,

On 13/09/2007, Mario Minati <mario.minati at googlemail.com> wrote:
> Today I had to implement a disabled form field, which should keep it's value
> no matter what the user sends in the form data.

Okay, when I was viewing the `svn diff`, I was wondering what it was
for - but that makes sense.

> So I created the 'force_default' attribute which overwrites the value in param
> with the default value.
> The changes and documentation is in Elements::_Field.

Tests needed! :)

Also, regarding this snippet...

    # if the default value has been changed after FormFu->process has been
    # called we respect the change here
    if (    $submitted
         && $self->force_default
         && defined $default
         && $new ne $default ) {
        $new = $default;

The comment contradicts the code.
It says "respect the change", but you're actually overwriting the change.
Would a more suitable comment just be...
# overwrite any changes

> BTW: I changed the formatting of a complex ??:?: to understand it.

Ok, but try to keep formatting changes to a separate commit, so if
anything needs rolled back, it's easier.

Anyway, that was perltidy's formatting, so your change will get lost
the next time I run perltidy on all the files.
To help with consistency, I've added my ".perltidyrc" file into the
trunk/HTML-FormFu directory, so if anyone else runs perltidy within
that folder, it'll use the same settings

If anyone's interested, the commands I use to run perltidy on all .pm
files in "lib" and all .t files in "t" are:

    $ find lib -name '*.pm' -exec perltidy -b '{}' \;
    $ find t -name '*.t' -exec perltidy -b '{}' \;

And to remove the backup files it creates:

    $ find lib -name '*.bak' -exec rm -f '{}' \;
    $ find t -name '*.bak' -exec rm -f '{}' \;


More information about the HTML-FormFu mailing list