1.1 --- a/MoinForms.py Mon Dec 03 01:15:19 2012 +0100
1.2 +++ b/MoinForms.py Mon Dec 03 01:47:09 2012 +0100
1.3 @@ -92,7 +92,7 @@
1.4 if isinstance(definition, dict):
1.5 if value:
1.6 for element in getSectionElements(value):
1.7 - valid = valid and self.validateFieldsUsingStructure(element, structure[key])
1.8 + valid = self.validateFieldsUsingStructure(element, structure[key]) and valid
1.9
1.10 # Validate individual fields.
1.11
1.12 @@ -104,7 +104,14 @@
1.13
1.14 if not value or not value[0]:
1.15 if field_args.get("required"):
1.16 - errors.append(_("This field must be filled out."))
1.17 +
1.18 + # Detect new parts of the structure and avoid producing
1.19 + # premature error messages.
1.20 +
1.21 + if not fields.has_key("_new"):
1.22 + errors.append(_("This field must be filled out."))
1.23 + else:
1.24 + valid = False
1.25 else:
1.26 # Test for unacceptable values.
1.27
1.28 @@ -214,10 +221,13 @@
1.29
1.30 # Where a section is found, get details from within the section.
1.31
1.32 - elif format == "form" and attributes.has_key("section"):
1.33 - section_name = attributes["section"]
1.34 - section = structure[section_name] = {}
1.35 - getFormStructure(body, request, path and ("%s/%s" % (path, section_name)) or section_name, section)
1.36 + elif format == "form":
1.37 + if attributes.has_key("section"):
1.38 + section_name = attributes["section"]
1.39 + section = structure[section_name] = {}
1.40 + getFormStructure(body, request, path and ("%s/%s" % (path, section_name)) or section_name, section)
1.41 + elif attributes.has_key("message"):
1.42 + getFormStructure(body, request, path, structure)
1.43
1.44 # Get field details from other kinds of region.
1.45