# HG changeset patch # User Paul Boddie # Date 1354400788 -3600 # Node ID 601968fcbaf14b7f3045d15b6ee77ec29d35ab63 # Parent fc84b1f78f1e86a58e129c0f3797b658bf09d12e Added support for multiple selection fields. Changed the formatting to not inhibit paragraphs since form regions are essentially not any different from normal page content. diff -r fc84b1f78f1e -r 601968fcbaf1 MoinForms.py --- a/MoinForms.py Sat Dec 01 20:38:35 2012 +0100 +++ b/MoinForms.py Sat Dec 01 23:26:28 2012 +0100 @@ -45,7 +45,7 @@ )) output = getFormOutput(text, fields) - write(formatText(output, request, fmt)) + write(formatText(output, request, fmt, inhibit_p=False)) write(fmt.rawHTML('')) diff -r fc84b1f78f1e -r 601968fcbaf1 macros/FormField.py --- a/macros/FormField.py Sat Dec 01 20:38:35 2012 +0100 +++ b/macros/FormField.py Sat Dec 01 23:26:28 2012 +0100 @@ -123,6 +123,7 @@ # Obtain any request parameters corresponding to the field. form = get_form(request) + values = form.get(ref, []) value = form.get(ref, [""])[0] # Render the field. @@ -154,12 +155,17 @@ if not sourcedict: return showError(_("WikiDict %s cannot be loaded for %s.") % (sourcedict, name), request) + size = field_args.get("size", [None])[0] + size = size and int(size) or size + output = [] - output.append(fmt.rawHTML('' % (escattr(ref), size != 1 and "multiple" or ""))) for option, label in sourcedict.items(): + is_selected = size == 1 and option == value or size != 1 and option in values + output.append(fmt.rawHTML('' % ( - escattr(option), value == option and "selected" or "", escape(label)) + escattr(option), is_selected and "selected" or "", escape(label)) )) output.append(fmt.rawHTML(''))