Ignore:
Timestamp:
13 Apr 2012, 21:44:00 (13 years ago)
Author:
uli
Message:

Register FormattedDateDisplayWidget? for FormattedDate? schema type.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/widgets/datewidget.py

    r8147 r8150  
    9292        self.date_format = getattr(context, 'date_format', self.date_format)
    9393        self.show_year = getattr(context, 'show_year', self.show_year)
    94         self.cssClass = FORMATS_BY_VALUE.get((
    95             self.date_format, self.show_year), self.cssClass)
     94        # add css class determined by date_format and show_year
     95        css_cls = FORMATS_BY_VALUE.get((self.date_format, self.show_year), '')
     96        self.cssClass = ' '.join([self.cssClass, css_cls]).strip()
    9697        return super(FormattedDateWidget, self).__init__(
    9798            context, request, *args, **kw)
     
    122123        return value
    123124
     125
    124126class FormattedDateDisplayWidget(DateDisplayWidget):
    125127    """A date widget that supports different (and _explicit_) date formats.
     
    128130    """
    129131    date_format = '%Y-%m-%d'
     132    show_year = False
     133
    130134    implements(IDisplayWidget)
     135
     136    def __init__(self, context, request, *args, **kw):
     137        # try to grab date_format and show_year from bound schema field.
     138        self.date_format = getattr(context, 'date_format', self.date_format)
     139        self.show_year = getattr(context, 'show_year', self.show_year)
     140        return super(FormattedDateDisplayWidget, self).__init__(
     141            context, request, *args, **kw)
    131142
    132143    def __call__(self):
Note: See TracChangeset for help on using the changeset viewer.