Changeset 246

Show
Ignore:
Timestamp:
07/13/06 10:54:36 (2 years ago)
Author:
matt
Message:

Add a class attribute to the Group's root element in the rendered HTML. The
value of the class attribute is 'group' appended by the optional
application-specific class passed to Group.init().

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r231 r246  
     12006-07-13  Matt Goodall <matt@pollenation.net> 
     2 
     3        Allow an application-specific CSS class to be assigned to a Group. The 
     4        class is included on the root element of the group. 
     5 
    162006-07-04  Matt Goodall <matt@pollenation.net> 
    27 
  • trunk/formal/__init__.py

    r241 r246  
    44 
    55 
    6 version_info = (0, 9, 1
     6version_info = (0, 9, 2
    77version = '.'.join([str(i) for i in version_info]) 
    88 
  • trunk/formal/examples/group.py

    r231 r246  
    1717 
    1818        def makePersonGroup(name): 
    19             person = formal.Group(name
     19            person = formal.Group(name, cssClass=name
    2020            person.add(formal.Field('name', formal.String(required=True))) 
    2121            person.add(formal.Field('dateOfBirth', formal.Date(required=True))) 
  • trunk/formal/form.py

    r240 r246  
    233233 
    234234 
    235     def __init__(self, name, label=None, description=None): 
     235    def __init__(self, name, label=None, description=None, cssClass=None): 
    236236        if label is None: 
    237237            label = util.titleFromName(name) 
     
    239239        self.label = label 
    240240        self.description = description 
     241        self.cssClass = cssClass 
    241242        self.items = FormItems(self) 
    242243        # Forward to FormItems methods 
     
    262263 
    263264    docFactory = loaders.stan( 
    264             T.fieldset(id=T.slot('id'), render=T.directive('group'))[ 
     265            T.fieldset(id=T.slot('id'), class_=T.slot('cssClass'), 
     266                    render=T.directive('group'))[ 
    265267                T.legend[T.slot('label')], 
    266268                T.div(class_='description')[T.slot('description')], 
     
    276278 
    277279    def render_group(self, ctx, data): 
     280 
     281        # Get a reference to the group, for simpler code. 
    278282        group = self.group 
     283 
     284        # Build the CSS class string 
     285        cssClass = ['group'] 
     286        if group.cssClass is not None: 
     287            cssClass.append(group.cssClass) 
     288        cssClass = ' '.join(cssClass) 
     289 
     290        # Fill the slots 
    279291        ctx.tag.fillSlots('id', util.render_cssid(group.key)) 
     292        ctx.tag.fillSlots('cssClass', cssClass) 
    280293        ctx.tag.fillSlots('label', group.label) 
    281294        ctx.tag.fillSlots('description', group.description or '') 
  • trunk/setup.py

    r241 r246  
    33setup( 
    44    name='formal', 
    5     version='0.9.1', 
     5    version='0.9.2', 
    66    description='HTML forms framework for Nevow', 
    77    author='Matt Goodall',