Changeset 247

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

Pull the group class change from trunk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/composite-2/ChangeLog

    r231 r247  
     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 
  • branches/composite-2/formal/__init__.py

    r243 r247  
    44 
    55 
    6 version_info = (0, 9, 1
     6version_info = (0, 9, 2
    77version = '.'.join([str(i) for i in version_info]) 
    88 
  • branches/composite-2/formal/examples/group.py

    r231 r247  
    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))) 
  • branches/composite-2/formal/form.py

    r243 r247  
    235235 
    236236 
    237     def __init__(self, name, label=None, description=None): 
     237    def __init__(self, name, label=None, description=None, cssClass=None): 
    238238        if label is None: 
    239239            label = util.titleFromName(name) 
     
    241241        self.label = label 
    242242        self.description = description 
     243        self.cssClass = cssClass 
    243244        self.items = FormItems(self) 
    244245        # Forward to FormItems methods 
     
    264265 
    265266    docFactory = loaders.stan( 
    266             T.fieldset(id=T.slot('id'), render=T.directive('group'))[ 
     267            T.fieldset(id=T.slot('id'), class_=T.slot('cssClass'), 
     268                    render=T.directive('group'))[ 
    267269                T.legend[T.slot('label')], 
    268270                T.div(class_='description')[T.slot('description')], 
     
    278280 
    279281    def render_group(self, ctx, data): 
     282 
     283        # Get a reference to the group, for simpler code. 
    280284        group = self.group 
     285 
     286        # Build the CSS class string 
     287        cssClass = ['group'] 
     288        if group.cssClass is not None: 
     289            cssClass.append(group.cssClass) 
     290        cssClass = ' '.join(cssClass) 
     291 
     292        # Fill the slots 
    281293        ctx.tag.fillSlots('id', util.render_cssid(group.key)) 
     294        ctx.tag.fillSlots('cssClass', cssClass) 
    282295        ctx.tag.fillSlots('label', group.label) 
    283296        ctx.tag.fillSlots('description', group.description or '') 
  • branches/composite-2/setup.py

    r241 r247  
    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',