Commits

Alessandro Molina committed d6087c5

Fix some minor issues with TW2

Comments (0)

Files changed (1)

smallpress/lib/forms.py

         return tg.url('/_pluggable/smallpress/images/spinner.gif')
 
 if tg.config.get('prefer_toscawidgets2', False):
-    from tw2.core import CSSLink
+    from tw2.core import CSSLink, Required
     from tw2.forms import DataGrid
-    from tw2.forms import ListForm, TextField, TextArea, HiddenField, FileField
+    from tw2.forms import ListForm, TextField, TextArea, HiddenField, FileField, SubmitButton
     from formencode.validators import UnicodeString, FieldStorageUploadConverter
 
     def inject_datagrid_resources(dg):
 
     class ArticleForm(ListForm):
         uid = HiddenField()
-        title = TextField(label='Title', validator=UnicodeString(not_empty=True))
-        description = TextField(label='Description', validator=UnicodeString(),
+        title = TextField(label='Title', validator=UnicodeString(not_empty=True, outputEncoding=None))
+        description = TextField(label='Description', validator=UnicodeString(outputEncoding=None),
                                 placeholder=l_('If empty will be extracted from the content'))
-        tags = TextField(label='Tags', validator=UnicodeString(),
+        tags = TextField(label='Tags', validator=UnicodeString(outputEncoding=None),
                          placeholder=l_('tags, comma separated'))
         content = TextArea(label=None, key='content', name='content', id="article_content",
-                           validator=UnicodeString(not_empty=True))
+                           validator=UnicodeString(not_empty=True, outputEncoding=None))
         publish_date = TextField(label='Publish Date')
 
     @ajaxloaded
     class UploadForm(ListForm):
         article = HiddenField()
-        name = TextField(label='Name', validator=UnicodeString(not_empty=True))
+        name = TextField(label='Name', validator=UnicodeString(not_empty=True, outputEncoding=None))
         file = FileField(label='File', validator=FieldStorageUploadConverter(not_empty=True))
 
         action = plug_url('smallpress', '/attach', lazy=True)
         ajaxurl = plug_url('smallpress', '/upload_form_show', lazy=True)
-        submit_text = 'Attach'
+
+        submit = SubmitButton(value='Attach')
 
     class SearchForm(ListForm):
-        text = TextField(label=None, validator=UnicodeString(not_empty=True),
+        text = TextField(label=None, validator=UnicodeString(not_empty=True, outputEncoding=None),
                          placeholder=l_('Search...'))
 
-        submit_text = 'Search'
+        submit = SubmitButton(value='Search')
 
 else:
     from tw.api import CSSLink