TGBooleanFormWidget - a TurboGears form widget

TGBooleanFormWidget is a form widget for TurboGears that is used to prompt the user for "yes/no" or "confirm/cancel" type decisions.

Download/Install:

Install with setuptools:

  $ easy_install TGBooleanFormWidget
  

Or download: TGBooleanFormWidget-0.1.egg

Screenshot:

Screenshot of TGBooleanFormWidget

Example:

in controller.py:
from tg_boolean_form_widget.tg_boolean_form_widget import BooleanForm

class Root(controllers.RootController):

  @expose(template='.templates.confirm')
  def confirm(self, id=None):
      return dict(
          form = BooleanForm(fields=[widgets.HiddenField('id')]),
          action = 'confirm_submit',
          no_text = 'Cancel',
          yes_text = 'Confirm',
          options = {},
          value = dict(
              id = id,
          ),
      )

  @expose()
  def confirm_submit(self, id=None, yes=None, no=None):
      if not yes:
          flash( _(u'Unpublish cancelled.') )
          redirect("confirm?id=%s"%id)

      flash( _(u"OK") )
      redirect("confirm?id=%s"%id)
The confirm.kid template would contain:
    <p py:content="form(method='GET', action=action, yes_text=yes_text, no_text=no_text, value=value, options=options)">Form goes here</p>

© Chris Miles 2007