Created
May 27, 2012 03:35
-
-
Save ralphbean/2802072 to your computer and use it in GitHub Desktop.
An attempt to invalidate the form in samples.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Here you can create samples of your widgets by providing default parameters, | |
| inserting them in a container widget, mixing them with other widgets, etc... | |
| These samples will appear in the WidgetBrowser | |
| See http://toscawidgets.org/documentation/WidgetBrowser for more information | |
| """ | |
| import tw2.core as twc | |
| from tw2.forms.samples import DemoChildren | |
| from tw2.bootstrap.widgets import * | |
| class DemoHorizontalForm(HorizontalForm): | |
| legend = 'Hi, I\'m form!' | |
| title = TextField(validator=twc.Required) | |
| #priority = SingleSelectField(options=['', 'Normal', 'High']) | |
| description = TextArea | |
| buttons = [SubmitButton, ResetButton] | |
| def prepare(self): | |
| super(DemoHorizontalForm, self).prepare() | |
| original, DemoHorizontalForm.parent = DemoHorizontalForm.parent, None | |
| try: | |
| # This will fail | |
| DemoHorizontalForm.validate({}) | |
| except: | |
| # Just so we know it failed. | |
| import traceback | |
| traceback.print_exc() | |
| finally: | |
| DemoHorizontalForm.parent = original |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a much better version of this here:
https://github.com/moschlar/tw2.bootstrap/commit/73c1d12d3719e1679035bb898b36f091690d51e5