The new form formula is pretty straightforward.
form = Form()
form.add_string(name, title='Name', required=True)
# If editing existing data, use the value= arg to set the initial value.
form.add_submit('save', 'Save')
if form.is_submitted(): # Or: choice = form.get_submit()
name = form['name'] # The value the user entered.
if form.has_errors(): # Maybe the user left a required field blank.
pass # The widget has already set the error.
elif name == name.lower():
form.get_widget('name').set_error('Lowercase name not allowed.')
else:
# Do some success action.
return redirect('next_page')
# At this point, the form is being shown for the first time or there was
# an input error.
return htmltext("<h1>What is your name?</h1>\n") + form.render()
There are several ways to refactor the if-blocks.
--
-- Mike Orr <[EMAIL PROTECTED]>
_______________________________________________
Quixote-users mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/quixote-users