[html-formfu] Constraints - Dynamic, RequiredWhen or extending Constraint and _others

Carl Franks fireartist at gmail.com
Tue Sep 18 11:50:23 GMT 2007


On 16/09/2007, Mario Minati <mario.minati at googlemail.com> wrote:
> Hi Carl,
>
> a few days ago I posted a Dynamic constraint with the idea of a constraining a
> textfield depending on the value of a different field, e. g. a select field.
>
> Today I needed to constrain many textfields depending on a radiogroup, as this
> radiogroup decides which fields needs to be filled, so I could put a required
> constraint on these fields.
>
> This bought me to the idea of extending 'process' in constraint and _others
> class (these are the base classes for al constraints) with a 'when' accessor
> and the code to only run the constraint when a specific field contains a
> given value (or the value is in a given range).
>
> I would suggest the following structure:
> - Required
>   when:
>     - field: name
>     - value: 1

minor nit-pick - that would be:

- type: Required
  when:
    - field: name
    - value: 1

> or
>     - values: [ 2, 4, 6 ]
>
> What do you think?

Yeah, that sounds good, go for it!

Carl



More information about the HTML-FormFu mailing list