def form_example(self, ctx): form = formal.Form() # This actually installs a RequiredValidator for you. form.addField('required', formal.String(required=True)) # Exactly the same as above, only with a "manually" installed validator. form.addField('required2', formal.String(validators=[formal.RequiredValidator()])) # Check for a minimum length, if anything entered. form.addField( 'atLeastFiveChars', formal.String(validators=[formal.LengthValidator(min=5)])) # Check for a minimum length, if anything entered. form.addField( 'ipAddress', formal.String(strip=True, validators=[ formal.PatternValidator(regex=IP_ADDRESS_PATTERN) ])) # Check for the word 'silly' form.addField('silly', formal.String(validators=[SillyValidator()])) # Check age is between 18 and 30 form.addField( 'ohToBeYoungAgain', formal.Integer(validators=[formal.RangeValidator(min=18, max=30)])) form.addAction(self.submitted) return form
def form_adminOps(self, ctx): form = formal.Form() if hasattr(self.clientRD, "currently_blocked"): label = "Unblock" else: label = "Block" form.addAction(self.toggleBlock, label=label, name="block") form.addAction(self.reloadRD, label="Reload RD", name="submit") return form
def form_example(self, ctx): form = formal.Form() form.addField('aString', formal.String()) form.addField('aTime', formal.Time()) form.addAction(self.submitted) form.data = { 'aTime': datetime.utcnow().time(), } return form
def form_example(self, ctx): form = formal.Form() form.addField('required', formal.String(required=True)) form.addField('file', formal.File(), formal.FileUploadWidget) form.addField( 'removeableFile', formal.File(), formal.widgetFactory(formal.FileUploadWidget, removeable=True)) form.addAction(self.submitted) return form
def form_example(self, ctx): form = formal.Form() form.addField( 'myTextArea', formal.String(), formal.widgetFactory(TextAreaWithSelect, values=(('aval', 'alabel'), ('bval', 'blabel')))) form.addAction(self.submitted) return form
def form_example(self, ctx): form = formal.Form() form.addField('hiddenString', formal.String(), widgetFactory=formal.Hidden) form.addField('hiddenInt', formal.Integer(), widgetFactory=formal.Hidden) form.addField('visibleString', formal.String()) form.addAction(self.submitted) form.data = { 'hiddenString': 'foo', 'hiddenInt': 1, } return form
def form_example(self, ctx): form = formal.Form() form.addField('required', formal.String(required=True)) form.addField( 'oneString', formal.String(), formal.widgetFactory(formal.SelectChoice, options=strings)) form.addField( 'anotherString', formal.String(), formal.widgetFactory(formal.SelectChoice, options=data_strings)) form.addField( 'oneMoreString', formal.String(required=True), formal.widgetFactory(formal.RadioChoice, options=data_strings)) form.addField('oneDate', formal.Date(), formal.widgetFactory(formal.SelectChoice, options=dates)) form.addField( 'multipleStrings', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, options=data_strings)) form.addField( 'multipleDates', formal.Sequence(formal.Date()), formal.widgetFactory(formal.CheckboxMultiChoice, options=dates)) form.addField( 'multipleTuples', formal.Sequence(formal.Sequence()), formal.widgetFactory(formal.CheckboxMultiChoice, options=tuples)) form.addField( 'differentNoneSelect', formal.String(), formal.widgetFactory(formal.SelectChoice, options=strings, noneOption=differentNone)) form.addField( 'differentNoneRadios', formal.String(), formal.widgetFactory(formal.RadioChoice, options=data_strings, noneOption=differentNone)) form.addField( 'selectOther', formal.String(), formal.widgetFactory(formal.SelectOtherChoice, options=['Mr', 'Mrs'])) form.addField( 'selectOtherCustomOther', formal.String(), formal.widgetFactory(formal.SelectOtherChoice, options=['Mr', 'Mrs'], otherOption=('...', 'Other (Please Enter)'))) form.addField( 'selectOtherRequired', formal.String(required=True), formal.widgetFactory(formal.SelectOtherChoice, options=['Mr', 'Mrs'])) form.addField( 'multiselect', formal.String(), formal.widgetFactory(formal.MultiselectChoice, options=strings)) form.addAction(self.submitted) return form
def form_example(self, ctx): form = formal.Form() form.addField('isoFormatDate', formal.Date(), formal.TextInput) form.addField('datePartsSelect', formal.Date(), formal.widgetFactory(formal.DatePartsSelect, dayFirst=True)) form.addField('monthFirstDate', formal.Date(), formal.DatePartsInput) form.addField('dayFirstDate', formal.Date(), formal.widgetFactory(formal.DatePartsInput, dayFirst=True)) form.addField('monthYearDate', formal.Date(), formal.MMYYDatePartsInput) form.addField('twoCharYearDate', formal.Date(), formal.widgetFactory(formal.DatePartsInput, twoCharCutoffYear=70)) form.addField('time', formal.Time()) form.addAction(self.submitted) return form
def form_example(self, ctx): form = formal.Form() form.addField('aString', formal.String()) form.addField('aInteger', formal.Integer()) form.addField('aFloat', formal.Float()) if haveDecimal: form.addField('aDecimal', formal.Decimal()) form.addField('aBoolean', formal.Boolean()) form.addField('aDate', formal.Date()) form.addField('aTime', formal.Time()) form.addAction(self.submitted) return form
def form_example(self, ctx): form = formal.Form() form.addField('restString', formal.String(required=True), widgetFactory=formal.ReSTTextArea) if docutilsAvailable: w = Writer() w.translator_class = CustomisedHTMLTranslator form.addField( 'customRestString', formal.String(required=True), formal.widgetFactory(formal.ReSTTextArea, restWriter=w)) form.addAction(self.submitted) return form
def form_setDowntime(self, ctx): form = formal.Form() form.addField( "scheduled", formal.String(), label="Schedule downtime for", description="Note that this is purely informative. The server" " will not take down the services at this point in time." " Leave empty to cancel. This will also be cleared on a" " reload.") form.addAction(self.setDowntime, label="Ok") form.data = { "scheduled": base.getMetaText(self.clientRD, "_scheduledDowntime") } return form
def form_example(self, ctx): form = formal.Form() form.addField('RichTextString', formal.RichTextType(required=True), widgetFactory=formal.widgetFactory( formal.RichTextArea, parsers=[('plain', 'Plain Text'), ('reverseplain', 'Reversed Plain Text')])) form.addField('RichTextStringNotRequired', formal.RichTextType(), widgetFactory=formal.widgetFactory( formal.RichTextArea, parsers=[('plain', 'Plain Text'), ('reverseplain', 'Reversed Plain Text'), ('html', 'XHTML')])) form.addField('RichTextStringOnlyOneParser', formal.RichTextType(required=True), widgetFactory=formal.widgetFactory(formal.RichTextArea, parsers=[('markdown', 'MarkDown') ])) form.addAction(self.submitted) return form
def form_example(self, ctx): def makeAddressGroup(name): address = formal.Group(name) address.add(formal.Field('address', formal.String())) address.add(formal.Field('city', formal.String())) address.add(formal.Field('postalCode', formal.String())) return address def makePersonGroup(name): person = formal.Group(name, cssClass=name) person.add(formal.Field('name', formal.String(required=True))) person.add(formal.Field('dateOfBirth', formal.Date(required=True))) person.add(makeAddressGroup('address')) return person form = formal.Form() form.add(formal.Field('before', formal.String())) form.add(makePersonGroup('me')) form.add(makePersonGroup('you')) form.add(formal.Field('after', formal.String())) form.addAction(self.submitted) return form
def form_genForm(self, ctx=None, data=None): # this is an accumulator for defaultForForm items processed; this # is used below to pre-fill forms without influencing service # behaviour in the absence of parameters. self._defaultsForForm = {} queryMeta = svcs.QueryMeta.fromContext(ctx) form = formal.Form() self._addQueryFields(form) self._addMetaFields(form, queryMeta) self._addDefaults(ctx, form, self._defaultsForForm) if (self.name == "form" and not hasattr(self.service.core, "HACK_RETURNS_DOC")): form.addField("_OUTPUT", formal.String, formal.widgetFactory(serviceresults.OutputFormat, self.service, queryMeta), label="Output format") form.addAction(self.submitAction, label="Go") form.actionMaterial = self._getFormLinks() self.form = form return form
def form_example(self, ctx): form = formal.Form() form.addAction(self.submitted) return form
def form_example(self, ctx): form = formal.Form() form.addField('aString', formal.String()) form.addAction(self.submitted) return form
def form_example(self, ctx): form = formal.Form() form.addField('aString', formal.String(required=True)) form.addAction(self.submitted, label="Click, click, clickety-click!") form.addAction(self.redirect, 'back', validate=False) return form
def form_example(self, ctx): form = formal.Form() form.addField('name', formal.String(required=True)) form.addField('age', formal.Integer()) form.addAction(self.submitted) return form
def form_example(self, ctx): form = formal.Form() form.addField('aString', formal.String(missing='<nothing>')) form.addField('aDate', formal.Date(missing=date(2005, 8, 1))) form.addAction(self.submitted) return form
def form_example(self, ctx): form = formal.Form() form.addField('file', formal.File()) form.addAction(self.submitted) return form