Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Created May 27, 2012 03:35
Show Gist options
  • Select an option

  • Save ralphbean/2802072 to your computer and use it in GitHub Desktop.

Select an option

Save ralphbean/2802072 to your computer and use it in GitHub Desktop.
An attempt to invalidate the form in samples.py
"""
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
@ralphbean
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment