[html-formfu] formfu usage

Carl Franks fireartist at gmail.com
Fri Aug 29 20:17:08 BST 2008


2008/8/29 Daniel Nicoletti <dantti85-perl at yahoo.com.br>:
> Hi,
> i don't know if here i where i can ask questions about how to use
> but anyway.
> I want to do a password match, i googled but could not find
> anything related to formfu.
> so i did
> $form->param_value('pass1') == $form->param_value('pass2')
> then i would like to add an error if the form is submitted
> but has different pass but i don't know how.

Use Constraint::Equal - for example:

    elements:
        - type: Password
          name: pass1
        - type: Password
          name: pass2
          constraints:
              - type: Equal
                others: pass1

> a second issue is about using label_for,
> is there some option to enable this?
> i really like label_for i can try to hack
> if this isn't implemented but i need directions.

If you give a field an 'id' and a 'label' - it'll automatically give
the label a for="" attribute.
For example, this config:

id: form
auto_id: %f_%n
elements:
    name: foo
    label: Foo

produces this output:

<form action="" id="form" method="post">
<div class="text label">
<label for="form_foo">Foo</label>
<input name="foo" type="text" id="form_foo" />
</div>
</form>

auto_id() gives every field an id attribute, where %f is replaced by
the form id, and %n is replaced by the field name.

Cheers,
Carl



More information about the HTML-FormFu mailing list