Hey all,
I'm trying to get validation working on MultipleSelectField and
CheckBoxLists and CheckBoxTables.
This is the widget form created:
# -*- coding: utf-8 -*-
""" root form: form on the first page """
from tw.api import WidgetsList
from tw.forms import TableForm, MultipleSelectField, CheckBoxList,
CheckBoxTable, InputField
from tw.forms.validators import Set, Empty, NotEmpty, Int
class RootForm(TableForm):
class fields(WidgetsList):
value_types_widget = MultipleSelectField(
label_text = 'Type',
help_text = 'Please select one or more experiment types',
validator = Set(not_empty=True)
)
annotations_widget = CheckBoxTable(
options = ['transcripts', 'genes', 'proteins'],
label_text = 'Annotation',
help_text = 'Please select one or more of the annotation
types',
validator = NotEmpty
)
timepoints_widget = CheckBoxTable(
label_text = 'Timepoints',
help_text = 'Please select timepoints',
validator = Int(not_empty=True)
)
#test_widget = InputField( validator = NotEmpty)
submit_text = 'Go!'
hover_help = True
show_errors = True
action = 'overview'
root_form = RootForm('root_form')
The only validation I want to do is make sure something is ticked or
selected, but none of the above methods really work. Also changing the
validator to Set, Set(non_empty=True) or leaving out the not_empty
param doesn't change anything.
If not commented out, the test_widget works as expected and displays
an error saying the input box cannot be empty.
I am using
tg2.1
tw.forms 0.9.9
ToscaWidgets 0.9.10
FormEncode 1.2.2
Any suggestions?
Kenny
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.