On Mar 26, 2008, at 12:52 PM, Carl Franks wrote:

On 26/03/2008, Andreas Marienborg <[EMAIL PROTECTED]> wrote:
Has anyone ever done anything with "dynamic forms", forms that change
when the users input changes? Specificaly I was thinking about chaning
some constraints based on the selected value in a dropdown.

The dropdown is a country dropdown, and I would like to change some
constraints for mobilephone, address, zipcode etc

Just wondering how I should implement such a scheme. I could perhaps
use when-clauses but it would quickly become cluttered

Mario added the 'when' method for this kind of thing.
I've never used it yet myself, but the code looks sane.

An example of use might be:

 - name: zip
   constraints:
     - type: US_Zipcode
       when:
         field: country
         value: us
     - type: Generic_Zipcode
       when:
         field: country
         not: 1
         value: us

Yeah, I actually already use the when stuff for some other, similar, cases, and it's working nicely.

Just gets messy if you have 4 different fields that should change, and each of them has 238 different values in country, so was wondering if someone else might have cooked up some ev0l scheme to fix it for me :)

- andreas

_______________________________________________
HTML-FormFu mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to