changeset 1437:368899856333

Alter the Tags widget to use JoinedString instead of MultiValue. With MultiValue, the flatland element is supposed to be flattened into multiple widgets, a mechanism we don't yet have in forms.html. With a single widget (WIDGET_TEXT), it is better to use JoinedString so that the list could be flattened into a single widget.
author Cheer Xiao <xiaqqaix@gmail.com>
date Tue, 24 Jul 2012 11:55:47 +0800
parents 1122533f76e6
children 9ab2ca1f385b
files MoinMoin/forms.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/forms.py	Tue Jul 17 23:52:59 2012 +0800
+++ b/MoinMoin/forms.py	Tue Jul 24 11:55:47 2012 +0800
@@ -8,7 +8,9 @@
 """
 
 
-from flatland import Element, Form, String, Integer, Boolean, Enum, MultiValue, Dict
+import re
+
+from flatland import Element, Form, String, Integer, Boolean, Enum, Dict, JoinedString
 from flatland.validation import Validator, Present, IsEmail, ValueBetween, URLValidator, Converted, ValueAtLeast
 
 from MoinMoin.constants.forms import *
@@ -50,7 +52,7 @@
 Select = Enum.with_properties(widget=WIDGET_SELECT)
 
 # XXX Need a better one than plain text box
-Tags = MultiValue.of(String).with_properties(widget=WIDGET_TEXT).using(label=L_('Tags'), optional=True)
+Tags = JoinedString.of(String).with_properties(widget=WIDGET_TEXT).using(label=L_('Tags'), optional=True, separator=', ', separator_regex=re.compile(r'\s*,\s*'))
 
 Search = Text.using(default=u'', optional=True).with_properties(widget=WIDGET_SEARCH, placeholder=L_("Search Query"))