# HG changeset patch # User Paul Boddie # Date 1354493719 -3600 # Node ID c25dbe02e053f0201ca37daefe40340ffb08662e # Parent 174626432da0d21d3075250854b20426a32321bd Restored the correct test for required values. Added support for form message regions. diff -r 174626432da0 -r c25dbe02e053 MoinForms.py --- a/MoinForms.py Mon Dec 03 01:08:19 2012 +0100 +++ b/MoinForms.py Mon Dec 03 01:15:19 2012 +0100 @@ -102,7 +102,7 @@ # Test for obligatory values. - if not value: + if not value or not value[0]: if field_args.get("required"): errors.append(_("This field must be filled out.")) else: @@ -294,6 +294,10 @@ elif format == "form": section_name = attributes.get("section") + message_name = attributes.get("message") + + # Sections are groups of fields in their own namespace. + if section_name and section.has_key(section_name): # Iterate over the section contents ignoring the given indexes. @@ -306,6 +310,12 @@ output.append(getFormOutput(body, element, path and ("%s/%s" % (path, element_ref)) or element_ref)) + # Message regions are conditional on a particular field and + # reference the current namespace. + + elif message_name and section.has_key(message_name): + output.append(getFormOutput(body, section, path)) + # Inspect and include other regions. else: