tw2.forms

This package contains the basic form widgets.

InputField

TextField
  • size
    • Size of the field
  • placeholder
    • Placeholder text (HTML5 Only)
class DemoTextField(twf.TextField):
    placeholder = "Search..."
<%namespace name="tw" module="tw2.core.mako_util"/>\
<input ${tw.attrs(attrs=w.attrs)}/>

TextArea
  • rows
    • Number of rows
  • cols
    • Number of columns
  • placeholder
    • Placeholder text (HTML5 Only)
class TextArea(FormField):
    rows = twc.Param('Number of rows', default=None, attribute=True)
    cols = twc.Param('Number of columns', default=None, attribute=True)
    placeholder = twc.Param(
        'Placeholder text (HTML5 Only)', attribute=True, default=None)
    template = "tw2.forms.templates.textarea"
<%namespace name="tw" module="tw2.core.mako_util"/>\
<textarea ${tw.attrs(attrs=w.attrs)}>${w.value or ''}</textarea>

CheckBox
    class DemoCheckBox(twf.CheckBox):
        value = True
    
    <%namespace name="tw" module="tw2.core.mako_util"/>\
    <input ${tw.attrs(attrs=w.attrs)}/>
    

    RadioButton
    • checked
      • Whether the field is selected
    class RadioButton(InputField):
        type = "radio"
        checked = twc.Param('Whether the field is selected',
                            attribute=True,
                            default=False)
    
    <%namespace name="tw" module="tw2.core.mako_util"/>\
    <input ${tw.attrs(attrs=w.attrs)}/>
    

    PasswordField
    A password field. This never displays a value passed into the widget, although it does redisplay entered values on validation failure. If no password is entered, this validates as EmptyField.
      class PasswordField(InputField):
          """
          A password field. This never displays a value passed into the widget,
          although it does redisplay entered values on validation failure. If no
          password is entered, this validates as EmptyField.
          """
          type = 'password'
          def prepare(self):
              super(PasswordField, self).prepare()
              self.safe_modify('attrs')
              self.attrs['value'] = None
          def _validate(self, value, state=None):
              value = super(PasswordField, self)._validate(value, state)
              return value or twc.EmptyField
      
      <%namespace name="tw" module="tw2.core.mako_util"/>\
      <input ${tw.attrs(attrs=w.attrs)}/>
      

      FileField

      A field for uploading files. The returned object has (at least) two properties of note:

      • filename:

        the name of the uploaded file

      • value:

        a bytestring of the contents of the uploaded file, suitable for being written to disk

        class FileField(InputField):
            """
            A field for uploading files.  The returned object has (at least) two
            properties of note:
             * filename:
                the name of the uploaded file
             * value:
                a bytestring of the contents of the uploaded file, suitable for being
                written to disk
            """
            type = "file"
            validator = FileValidator
            def prepare(self):
                self.value = None
                super(FileField, self).prepare()
            def _validate(self, value, state=None):
                try:
                    return super(FileField, self)._validate(value, state)
                except twc.ValidationError:
                    self.value = None
                    raise
        
        <%namespace name="tw" module="tw2.core.mako_util"/>\
        <input ${tw.attrs(attrs=w.attrs)}/>
        

        HiddenField
        A hidden field.
          class HiddenField(InputField):
              """
              A hidden field.
              """
              type = 'hidden'
          
          <%namespace name="tw" module="tw2.core.mako_util"/>\
          <input ${tw.attrs(attrs=w.attrs)}/>
          

          IgnoredField
          A hidden field. The value is never included in validated data.
            class IgnoredField(HiddenField):
                """
                A hidden field. The value is never included in validated data.
                """
                def _validate(self, value):
                    super(IgnoredField, self)._validate(value)
                    return twc.EmptyField
            
            <%namespace name="tw" module="tw2.core.mako_util"/>\
            <input ${tw.attrs(attrs=w.attrs)}/>
            

            LabelField
            A read-only label showing the value of a field. The value is stored in a hidden field, so it remains through validation failures. However, the value is never included in validated data.
              class LabelField(InputField):
                  """
                  A read-only label showing the value of a field. The value is stored in a
                  hidden field, so it remains through validation failures. However, the
                  value is never included in validated data.
                  """
                  type = 'hidden'
                  template = "tw2.forms.templates.label_field"
                  validator = twc.BlankValidator
              
              <%namespace name="tw" module="tw2.core.mako_util"/>\
              <span>${unicode(w.value or '')}<input ${tw.attrs(attrs=w.attrs)}/></span>
              

              LinkField
              A dynamic link based on the value of a field. If either link or text contain a $, it is replaced with the field value. If the value is None, and there is no default, the entire link is hidden.
              • link
                • Link target
              • text
                • Link text
              class LinkField(twc.Widget):
                  """
                  A dynamic link based on the value of a field. If either *link* or *text*
                  contain a $, it is replaced with the field value. If the value is None,
                  and there is no default, the entire link is hidden.
                  """
                  template = "tw2.forms.templates.link_field"
                  link = twc.Param('Link target', default='')
                  text = twc.Param('Link text', default='')
                  value = twc.Param("Value to replace $ with in the link/text")
                  validator = twc.BlankValidator
                  def prepare(self):
                      super(LinkField, self).prepare()
                      self.safe_modify('attrs')
                      self.attrs['href'] = self.link.replace('$', six.text_type(self.value or ''))
                      if '$' in self.text:
                          self.text = \
                                  self.value and \
                                  self.text.replace('$', six.text_type(self.value)) or \
                                  ''
              
              <%namespace name="tw" module="tw2.core.mako_util"/>\
              <a ${tw.attrs(attrs=w.attrs)}>${w.text}</a>
              

              Button
              Generic button. You can override the text using value and define a
              JavaScript action using attrs['onclick'].
                class DemoButton(twf.Button):
                    value = 'Click me'
                    attrs = {'onclick': 'alert("Hello")'}
                
                <%namespace name="tw" module="tw2.core.mako_util"/>\
                <input ${tw.attrs(attrs=w.attrs)}/>
                

                SubmitButton

                Button to submit a form.

                  class SubmitButton(Button):
                      """Button to submit a form."""
                      type = "submit"
                      name = None
                  
                  <%namespace name="tw" module="tw2.core.mako_util"/>\
                  <input ${tw.attrs(attrs=w.attrs)}/>
                  

                  ResetButton

                  Button to clear the values in a form.

                    class ResetButton(Button):
                        """Button to clear the values in a form."""
                        type = "reset"
                    
                    <%namespace name="tw" module="tw2.core.mako_util"/>\
                    <input ${tw.attrs(attrs=w.attrs)}/>
                    

                    ImageButton
                    • location
                      • Location on the page where the resource should be placed.This can be one of: head, headbottom, bodytop or bodybottom. None means the resource will not be injected, which is still useful, e.g. static images.
                    • modname
                      • Name of Python module that contains the file.
                    • filename
                      • Path to file, relative to module base.
                    • no_inject
                      • Don't inject this link. (Default: False)
                    • whole_dir
                      • Make the whole directory available. (Default: False)
                    • width
                      • Width of image in pixels
                    • height
                      • Height of image in pixels
                    • alt
                      • Alternate text
                    class DemoImageButton(twf.ImageButton):
                        modname = 'tw2.forms'
                        filename = 'static/edit-undo.png'
                    
                    <%namespace name="tw" module="tw2.core.mako_util"/>\
                    <input ${tw.attrs(attrs=w.attrs)}/>
                    

                    SelectionField

                    Base class for single and multiple selection fields.

                    The options parameter must be a list; it can take several formats:

                    • A list of values, e.g. ['', 'Red', 'Blue']
                    • A list of (code, value) tuples, e.g. [(0, ''), (1, 'Red'), (2, 'Blue')]
                    • A mixed list of values and tuples. If the code is not specified, it defaults to the value. e.g. ['', (1, 'Red'), (2, 'Blue')]
                    • Attributes can be specified for individual items, e.g. [(1, 'Red', {'style':'background-color:red'})]
                    • A list of groups, e.g. [('group1', [(1, 'Red')]), ('group2', ['Pink', 'Yellow'])]

                    Setting value before rendering will set the default displayed value on the page. In ToscaWidgets1, this was accomplished by setting default. That is no longer the case.

                    • prompt_text
                      • Text to prompt user to select an option.

                    MultipleSelectionField
                    • prompt_text
                      • Text to prompt user to select an option.
                    • item_validator
                      • Validator that applies to each item

                    SingleSelectField
                    • prompt_text
                      • Text to prompt user to select an option.
                    class DemoSingleSelectField(twf.SingleSelectField):
                        options = ['Red', 'Orange', 'Yellow', 'Green', 'Blue']
                    
                    <%namespace name="tw" module="tw2.core.mako_util"/>\
                    <select ${tw.attrs(attrs=w.attrs)}>
                        % for group, options in w.grouped_options:
                         % if group:
                          <optgroup ${tw.attrs(attrs=dict(label=group))}>
                         % endif 
                            % for attrs, desc in options:
                             <option ${tw.attrs(attrs=attrs)}>${desc}</option>
                            % endfor
                         % if group:
                          </optgroup>
                         % endif 
                        % endfor
                    </select>
                    

                    MultipleSelectField
                    • prompt_text
                      • Text to prompt user to select an option.
                    • item_validator
                      • Validator that applies to each item
                    • size
                      • Number of visible options
                    class DemoMultipleSelectField(twf.MultipleSelectField):
                        options = ['Red', 'Orange', 'Yellow', 'Green', 'Blue']
                    
                    <%namespace name="tw" module="tw2.core.mako_util"/>\
                    <select ${tw.attrs(attrs=w.attrs)}>
                        % for group, options in w.grouped_options:
                         % if group:
                          <optgroup ${tw.attrs(attrs=dict(label=group))}>
                         % endif 
                            % for attrs, desc in options:
                             <option ${tw.attrs(attrs=attrs)}>${desc}</option>
                            % endfor
                         % if group:
                          </optgroup>
                         % endif 
                        % endfor
                    </select>
                    

                    RadioButtonList
                    • prompt_text
                      • Text to prompt user to select an option.
                    class DemoRadioButtonList(twf.RadioButtonList):
                        options = ['Red', 'Orange', 'Yellow', 'Green', 'Blue']
                    
                    <%namespace name="tw" module="tw2.core.mako_util"/>\
                    <ul ${tw.attrs(attrs=w.attrs)}>
                       % for group, opts in w.grouped_options:
                           % if group:
                            <li>
                            <div class="group_header">${group}</div>
                            <ul>
                           % endif   
                           % for attrs, desc in opts:
                            <li>
                                <input ${tw.attrs(attrs=attrs)}/>
                                <label for="${attrs['id']}">${desc}</label>
                            </li>
                           % endfor
                           % if group:
                            </li>
                            </ul>
                           % endif   
                       % endfor
                    </ul>
                    

                    CheckBoxList
                    • prompt_text
                      • Text to prompt user to select an option.
                    • item_validator
                      • Validator that applies to each item
                    class DemoCheckBoxList(twf.CheckBoxList):
                        options = ['Red', 'Orange', 'Yellow', 'Green', 'Blue']
                    
                    <%namespace name="tw" module="tw2.core.mako_util"/>\
                    <ul ${tw.attrs(attrs=w.attrs)}>
                       % for group, opts in w.grouped_options:
                           % if group:
                            <li>
                            <div class="group_header">${group}</div>
                            <ul>
                           % endif   
                           % for attrs, desc in opts:
                            <li>
                                <input ${tw.attrs(attrs=attrs)}/>
                                <label for="${attrs['id']}">${desc}</label>
                            </li>
                           % endfor
                           % if group:
                            </li>
                            </ul>
                           % endif   
                       % endfor
                    </ul>
                    

                    RadioButtonTable
                    • prompt_text
                      • Text to prompt user to select an option.
                    • cols
                      • Number of columns
                    class DemoRadioButtonTable(twf.RadioButtonTable):
                        options = ['Red', 'Orange', 'Yellow', 'Green', 'Blue']
                        cols = 2
                    
                    <%namespace name="tw" module="tw2.core.mako_util"/>\
                    <table ${tw.attrs(attrs=w.attrs)}>
                        <tbody>
                       % for row in w.options_rows:
                        <tr>
                           % for attrs, desc in row:
                            <td>
                                <input ${tw.attrs(attrs=attrs)} />
                                <label for="${attrs['id']}">${desc}</label>
                            </td>
                           % endfor
                           % for j in xrange(w.cols - len(row)):
                            <td/>
                           % endfor
                        </tr>
                       % endfor
                        </tbody>
                    </table>
                    

                    SeparatedRadioButtonTable
                    • prompt_text
                      • Text to prompt user to select an option.
                    • item_validator
                      • Validator that applies to each item

                    VerticalRadioButtonTable
                    • prompt_text
                      • Text to prompt user to select an option.
                    • cols
                      • Number of columns. If the options are grouped, this is overidden.

                    CheckBoxTable
                    • prompt_text
                      • Text to prompt user to select an option.
                    • item_validator
                      • Validator that applies to each item
                    • cols
                      • Number of columns
                    class DemoCheckBoxTable(twf.CheckBoxTable):
                        options = ['Red', 'Orange', 'Yellow', 'Green', 'Blue']
                        value = ['Red', 'Green', 'Blue']  # These are the selected items
                        cols = 2
                    
                    <%namespace name="tw" module="tw2.core.mako_util"/>\
                    <table ${tw.attrs(attrs=w.attrs)}>
                        <tbody>
                       % for row in w.options_rows:
                        <tr>
                           % for attrs, desc in row:
                            <td>
                                <input ${tw.attrs(attrs=attrs)} />
                                <label for="${attrs['id']}">${desc}</label>
                            </td>
                           % endfor
                           % for j in xrange(w.cols - len(row)):
                            <td/>
                           % endfor
                        </tr>
                       % endfor
                        </tbody>
                    </table>
                    

                    SeparatedCheckBoxTable
                    • prompt_text
                      • Text to prompt user to select an option.
                    • item_validator
                      • Validator that applies to each item

                    VerticalCheckBoxTable
                    • prompt_text
                      • Text to prompt user to select an option.
                    • cols
                      • Number of columns. If the options are grouped, this is overidden.

                    TableLayout

                    Arrange widgets and labels in a table.

                    The following CSS classes are used, on the element containing both a child widget and its label.

                    odd / even
                    On alternating rows. The first row is odd.
                    required
                    If the field is a required field.
                    error
                    If the field contains a validation error.
                    • hover_help
                      • Whether to display help text as hover tips
                    class DemoTableLayout(twf.TableLayout, DemoChildren):
                        pass
                    
                    <%namespace name="tw" module="tw2.core.mako_util"/>\
                    <table ${tw.attrs(attrs=w.attrs)}>
                       % for i,c in enumerate(w.children_non_hidden):
                        <tr class="${(i % 2 and 'even' or 'odd') + ((c.validator and getattr(c.validator, 'required', getattr(c.validator, 'not_empty', False))) and ' required' or '') + (c.error_msg and ' error' or '')}" \
                         %if w.hover_help and c.help_text:
                          title="${c.help_text}" \
                         %endif
                    ${tw.attrs(attrs=c.container_attrs)} \
                    id="${c.compound_id or ''}:container">
                           % if c.label:
                            <th><label for="${c.id}">${c.label}</label></th>
                           % endif
                            <td \
                           % if not c.label:
                    colspan="2"\
                           % endif
                    >
                                ${c.display() | n}
                               % if not w.hover_help:
                                ${c.help_text or ''}
                               % endif
                                <span id="${c.compound_id or ''}:error">${c.error_msg or ''}</span>
                            </td>
                        </tr>
                       % endfor
                        <tr class="error"><td colspan="2">
                           % for c in w.children_hidden:
                            ${c.display() | n}
                           % endfor
                            <span id="${w.compound_id or ''}:error">${w.error_msg or ''}</span>
                        </td></tr>
                    </table>
                    

                    ListLayout

                    Arrange widgets and labels in a list.

                    The following CSS classes are used, on the element containing both a child widget and its label.

                    odd / even
                    On alternating rows. The first row is odd.
                    required
                    If the field is a required field.
                    error
                    If the field contains a validation error.
                    • hover_help
                      • Whether to display help text as hover tips
                    class DemoListLayout(twf.ListLayout, DemoChildren):
                        pass
                    
                    <%namespace name="tw" module="tw2.core.mako_util"/>\
                    <ul ${tw.attrs(attrs=w.attrs)}>
                       % for c in w.children_hidden:
                        ${c.display() | n}
                       % endfor
                       % for i,c in enumerate(w.children_non_hidden):
                        <li \
                    class="${(i % 2 and 'even' or 'odd') + ((c.validator and getattr(c.validator, 'required', getattr(c.validator, 'not_empty', False))) and ' required' or '') + (c.error_msg and ' error' or '')}"\
                         % if w.hover_help and c.help_text:
                    title="${c.help_text}" \
                         % endif
                    ${tw.attrs(attrs=c.container_attrs)}\
                    >
                         <label for="${c.id}">${c.label or ''}</label>
                            ${c.display() | n}
                            % if not w.hover_help:
                    ${c.help_text or ''}\
                            % endif
                            <span id="${c.compound_id or ''}:error" class="error">${c.error_msg or ''}</span>
                        </li>
                       % endfor
                       <li class="error"><span id="${w.compound_id or ''}:error" class="error">\
                            %for error in w.rollup_errors:
                                <p>${error}</p>
                            %endfor
                        </span></li>
                    </ul>
                    

                    RowLayout

                    Arrange widgets in a table row. This is normally only useful as a child to :class:`GridLayout`.

                    System Message: ERROR/3 (<string>, line 2); backlink

                    Unknown interpreted text role "class".
                    • hover_help
                      • Whether to display help text as hover tips

                    GridLayout
                    Title Priority
                    Arrange labels and multiple rows of widgets in a grid.
                    • child
                      • Child for this widget. The child must have no id.
                    • repetitions
                      • Fixed number of repetitions. If this is None, it dynamically determined, based on the length of the value list.
                    • min_reps
                      • Minimum number of repetitions
                    • max_reps
                      • Maximum number of repetitions
                    • extra_reps
                      • Number of extra repeitions, beyond the length of the value list.
                    class DemoGridLayout(twf.GridLayout):
                        id = 'x'
                        extra_reps = 3
                        title = twf.TextField()
                        priority = twf.SingleSelectField(options=['', 'Normal', 'High'])
                    
                    <%namespace name="tw" module="tw2.core.mako_util"/>\
                    <table ${tw.attrs(attrs=w.attrs)}>
                    <tr>\
                    % for col in w.children[0].children_non_hidden:
                        <th>${unicode(col.label)}</th>
                    % endfor
                    </tr>
                    % for row in w.children:
                        ${row.display() | n}
                    % endfor
                        <tr class="error"><td colspan="${str(len(w.children))}" id="${w.compound_id or ''}:error">
                            ${w.error_msg or ''}
                        </td></tr>
                    </table>
                    

                    Spacer
                     
                    A blank widget, used to insert a blank row in a layout.
                      class DemoSpacer(twf.TableLayout):
                          demo_for = twf.Spacer
                          title = twf.TextField()
                          xx = twf.Spacer()
                          description = twf.TextArea()
                      
                      <%namespace name="tw" module="tw2.core.mako_util"/>\
                      <table ${tw.attrs(attrs=w.attrs)}>
                         % for i,c in enumerate(w.children_non_hidden):
                          <tr class="${(i % 2 and 'even' or 'odd') + ((c.validator and getattr(c.validator, 'required', getattr(c.validator, 'not_empty', False))) and ' required' or '') + (c.error_msg and ' error' or '')}" \
                           %if w.hover_help and c.help_text:
                            title="${c.help_text}" \
                           %endif
                      ${tw.attrs(attrs=c.container_attrs)} \
                      id="${c.compound_id or ''}:container">
                             % if c.label:
                              <th><label for="${c.id}">${c.label}</label></th>
                             % endif
                              <td \
                             % if not c.label:
                      colspan="2"\
                             % endif
                      >
                                  ${c.display() | n}
                                 % if not w.hover_help:
                                  ${c.help_text or ''}
                                 % endif
                                  <span id="${c.compound_id or ''}:error">${c.error_msg or ''}</span>
                              </td>
                          </tr>
                         % endfor
                          <tr class="error"><td colspan="2">
                             % for c in w.children_hidden:
                              ${c.display() | n}
                             % endfor
                              <span id="${w.compound_id or ''}:error">${w.error_msg or ''}</span>
                          </td></tr>
                      </table>
                      

                      Label
                      Please enter as much information as possible in the description.
                      A textual label. This disables any label that would be displayed by a parent layout.
                      • escape
                        • Whether text shall be html-escaped or not
                      class DemoLabel(twf.TableLayout):
                          demo_for = twf.Label
                          title = twf.TextField()
                          xx = twf.Label(
                              text='Please enter as much information as possible in the description.'
                          )
                          description = twf.TextArea()
                      
                      <%namespace name="tw" module="tw2.core.mako_util"/>\
                      <table ${tw.attrs(attrs=w.attrs)}>
                         % for i,c in enumerate(w.children_non_hidden):
                          <tr class="${(i % 2 and 'even' or 'odd') + ((c.validator and getattr(c.validator, 'required', getattr(c.validator, 'not_empty', False))) and ' required' or '') + (c.error_msg and ' error' or '')}" \
                           %if w.hover_help and c.help_text:
                            title="${c.help_text}" \
                           %endif
                      ${tw.attrs(attrs=c.container_attrs)} \
                      id="${c.compound_id or ''}:container">
                             % if c.label:
                              <th><label for="${c.id}">${c.label}</label></th>
                             % endif
                              <td \
                             % if not c.label:
                      colspan="2"\
                             % endif
                      >
                                  ${c.display() | n}
                                 % if not w.hover_help:
                                  ${c.help_text or ''}
                                 % endif
                                  <span id="${c.compound_id or ''}:error">${c.error_msg or ''}</span>
                              </td>
                          </tr>
                         % endfor
                          <tr class="error"><td colspan="2">
                             % for c in w.children_hidden:
                              ${c.display() | n}
                             % endfor
                              <span id="${w.compound_id or ''}:error">${w.error_msg or ''}</span>
                          </td></tr>
                      </table>
                      

                      Form
                      A form, with a submit button. It's common to pass a TableLayout or ListLayout widget as the child.
                      • children
                        • Children specified for this widget will be passed to the child
                      • id_suffix
                        • Suffix to append to compound IDs
                      • help_msg
                        • This message displays as a div inside the form
                      • action
                        • URL to submit form data to. If this is None, the form submits to the same URL it was displayed on.
                      • method
                        • HTTP method used for form submission.
                      • submit
                        • Submit button widget. If this is None, no submit button is generated.
                      • buttons
                        • List of additional buttons to be placed at the bottom of the form
                      class DemoForm(twf.Form):
                          child = DemoTableLayout()
                          buttons = [twf.ResetButton()]
                      
                      <%namespace name="tw" module="tw2.core.mako_util"/>\
                      <form ${tw.attrs(attrs=w.attrs)}>
                           <span class="error">${w.error_msg or ''}</span>
                           % if w.help_msg:
                           <div class="help">
                            <p>
                               ${w.help_msg}
                            </p>
                           </div>
                           % endif
                          ${w.child.display() | n}
                      	% for button in w.buttons:
                      		${button.display() | n}
                      	% endfor
                      </form>
                      

                      FieldSet
                      FieldSet
                      A field set. It's common to pass a TableLayout or ListLayout widget as the child.
                      • children
                        • Children specified for this widget will be passed to the child
                      • id_suffix
                        • Suffix to append to compound IDs
                      • legend
                        • Text for the legend
                      class DemoFieldSet(twf.FieldSet):
                          legend = 'FieldSet'
                          child = DemoTableLayout()
                      
                      <%namespace name="tw" module="tw2.core.mako_util"/>\
                      <fieldset ${tw.attrs(attrs=w.attrs)}>
                          <legend>${w.legend or ''}</legend>
                          ${w.child.display() | n}
                      </fieldset>
                      

                      TableForm

                      Equivalent to a Form containing a TableLayout.

                      • id_suffix
                        • Suffix to append to compound IDs
                      • help_msg
                        • This message displays as a div inside the form
                      • action
                        • URL to submit form data to. If this is None, the form submits to the same URL it was displayed on.
                      • method
                        • HTTP method used for form submission.
                      • submit
                        • Submit button widget. If this is None, no submit button is generated.
                      • buttons
                        • List of additional buttons to be placed at the bottom of the form

                      ListForm

                      Equivalent to a Form containing a ListLayout.

                      • id_suffix
                        • Suffix to append to compound IDs
                      • help_msg
                        • This message displays as a div inside the form
                      • action
                        • URL to submit form data to. If this is None, the form submits to the same URL it was displayed on.
                      • method
                        • HTTP method used for form submission.
                      • submit
                        • Submit button widget. If this is None, no submit button is generated.
                      • buttons
                        • List of additional buttons to be placed at the bottom of the form

                      TableFieldSet

                      Equivalent to a FieldSet containing a TableLayout.

                      • id_suffix
                        • Suffix to append to compound IDs
                      • legend
                        • Text for the legend

                      ListFieldSet

                      Equivalent to a FieldSet containing a ListLayout.

                      • id_suffix
                        • Suffix to append to compound IDs
                      • legend
                        • Text for the legend

                      FormPage

                      A page that contains a form. The :meth:`request` method performs validation, redisplaying the form on errors. On success, it calls :meth:`validated_request`.

                      System Message: ERROR/3 (<string>, line 2); backlink

                      Unknown interpreted text role "meth".

                      System Message: ERROR/3 (<string>, line 2); backlink

                      Unknown interpreted text role "meth".
                      • children
                        • Children specified for this widget will be passed to the child
                      • id_suffix
                        • Suffix to append to compound IDs
                      • content_type
                        • Content type header

                      PostlabeledCheckBox
                      • text_attrs
                        • Dict of attributes to inject into the label.

                      PostlabeledPartialRadioButton
                      This is basically a manual mixin of RadioButton and
                      IgnoredField. Inheritance doesn't work.
                      • text_attrs
                        • Dict of attributes to inject into the label.
                      • checked
                        • None

                      CalendarDatePicker
                      Uses a javascript calendar system to allow picking of calendar dates. The date_format is in mm/dd/yyyy unless otherwise specified
                      • calendar_lang
                        • Default Language to use in the Calendar
                      • required
                        • None
                      • button_text
                        • Text to display on Button
                      • date_format
                        • Date Display Format
                      • picker_shows_time
                        • Picker Shows Time
                      • tzinfo
                        • Time Zone Information
                      • setup_options
                        • Calendar.setup(...) options
                      • default
                        • Default value (datetime) for the widget. If set to a function, it will be called each time before displaying.
                      class CalendarDatePicker(FormField):
                          """
                          Uses a javascript calendar system to allow picking of calendar dates.
                          The date_format is in mm/dd/yyyy unless otherwise specified
                          """
                          template = "tw2.forms.templates.calendar"
                          calendar_lang = twc.Param("Default Language to use in the Calendar",
                                                    default='en')
                          required = twc.Param(default=False)
                          button_text = twc.Param("Text to display on Button", default="Choose")
                          date_format = twc.Param("Date Display Format", default="%m/%d/%Y")
                          picker_shows_time = twc.Param('Picker Shows Time', default=False)
                          tzinfo = twc.Param('Time Zone Information', default=None)
                          setup_options = twc.Param('Calendar.setup(...) options', default={})
                      #    validator = None
                          default = twc.Param(
                              'Default value (datetime) for the widget.  If set to a function, ' +
                              'it will be called each time before displaying.',
                              default=datetime.now)
                          def get_calendar_lang_file_link(self, lang):
                              """
                              Returns a CalendarLangFileLink containing a list of name
                              patterns to try in turn to find the correct calendar locale
                              file to use.
                              """
                              fname = 'static/calendar/lang/calendar-%s.js' % lang.lower()
                              return twc.JSLink(modname='tw2.forms',
                                            filename=fname)
                          def __init__(self, *args, **kw):
                              if self.validator is None:
                                  self.validator = twc.DateTimeValidator(
                                  format=self.date_format,
                                  required=self.required
                                  )
                              super(CalendarDatePicker, self).__init__(*args, **kw)
                          def prepare(self):
                              super(CalendarDatePicker, self).prepare()
                              self.resources = [calendar_css, calendar_js, calendar_setup]
                              if not self.value and self.required:
                                  if callable(self.default):
                                      self.value = self.default()
                                  else:
                                      self.value = self.default
                              try:
                                  self.strdate = self.value.strftime(self.date_format)
                              except AttributeError:
                                  self.strdate = self.value
                              self.resources.append(
                                  self.get_calendar_lang_file_link(self.calendar_lang)
                              )
                      
                      <%! import tw2.core as twc %>
                      <div>
                        <input type="text" id="${w.compound_id}" name="${w.name}" class="${w.css_class or ''}" value="${w.strdate or ''}" />
                        <input type="button" id="${w.compound_id}_trigger" class="date_field_button" value="${w.button_text}" />
                        <script type="text/javascript">Calendar.setup({
                          "inputField": "${w.compound_id}", "showsTime": ${str(w.picker_shows_time).lower()},
                          "ifFormat": "${w.date_format}", "button": "${w.compound_id}_trigger"
                          %for k, v in w.setup_options.items():
                            , ${k}: ${isinstance(v, twc.JSSymbol) and (v.src) or '"%s"' % v}
                          %endfor
                        })</script>
                      </div>\
                      

                      CalendarDateTimePicker
                      Use a javascript calendar system to allow picking of calendar dates and time. The date_format is in mm/dd/yyyy hh:mm unless otherwise specified
                      • calendar_lang
                        • Default Language to use in the Calendar
                      • required
                        • None
                      • button_text
                        • Text to display on Button
                      • date_format
                        • Date Display Format
                      • picker_shows_time
                        • Picker Shows Time
                      • tzinfo
                        • Time Zone Information
                      • setup_options
                        • Calendar.setup(...) options
                      • default
                        • Default value (datetime) for the widget. If set to a function, it will be called each time before displaying.
                      class CalendarDateTimePicker(CalendarDatePicker):
                          """
                          Use a javascript calendar system to allow picking of calendar dates and
                          time.
                          The date_format is in mm/dd/yyyy hh:mm unless otherwise specified
                          """
                          messages = {
                              'badFormat': 'Invalid datetime format.',
                              'empty': 'Please Enter a Date and Time.',
                          }
                          date_format = "%Y/%m/%d %H:%M"
                          picker_shows_time = True
                      
                      <%! import tw2.core as twc %>
                      <div>
                        <input type="text" id="${w.compound_id}" name="${w.name}" class="${w.css_class or ''}" value="${w.strdate or ''}" />
                        <input type="button" id="${w.compound_id}_trigger" class="date_field_button" value="${w.button_text}" />
                        <script type="text/javascript">Calendar.setup({
                          "inputField": "${w.compound_id}", "showsTime": ${str(w.picker_shows_time).lower()},
                          "ifFormat": "${w.date_format}", "button": "${w.compound_id}_trigger"
                          %for k, v in w.setup_options.items():
                            , ${k}: ${isinstance(v, twc.JSSymbol) and (v.src) or '"%s"' % v}
                          %endfor
                        })</script>
                      </div>\
                      

                      DataGrid
                      Column-0 Column-1
                      Jimmy John Fancy pancy street.
                      Sally Sue Fancy pancy street.

                      Generic widget to present and manipulate data in a grid (tabular) form.

                      The columns to build the grid from are specified with fields constructor argument which is a list. An element can be a Column, an accessor (attribute name or function), a tuple (title, accessor) or a tuple (title, accessor, options).

                      You can specify columns' data statically, via fields constructor parameter, or dynamically, via 'fields' key.

                      • fields
                        • Fields of the Grid
                      class DemoDataGrid(dg.DataGrid):
                          class DummyObject(object):
                              def __init__(self, name):
                                  self._name = name
                              def name(self):
                                  return self._name
                              def address(self):
                                  return "Fancy pancy street."
                          value = [
                              DummyObject("Jimmy John"),
                              DummyObject("Sally Sue"),
                          ]
                          fields = [DummyObject.name, DummyObject.address]
                      
                      <%namespace name="tw" module="tw2.core.mako_util"/>\
                      <table ${tw.attrs(attrs=w.attrs)} cellpadding="0" cellspacing="1" border="0">
                          % if w.columns:
                          <thead>
                              <tr>
                                  % for i, col in enumerate(w.columns):
                                  <th class="col_${str(i)}">${col.title}</th>
                                  % endfor
                              </tr>
                          </thead>
                          % endif
                          <tbody>
                              % for i, row in enumerate(w.value):
                              <tr class="${i%2 and 'odd' or 'even'}">
                                  % for col in w.columns:
                                  <td ${tw.attrs(
                          [('align', col.get_option('align', None)),
                           ('class', col.get_option('css_class', None))],
                      )}>${col.get_field(row)}</td>
                                  % endfor
                              </tr>
                              % endfor
                          </tbody>
                      </table>\