web/formwidgets.py
branchtls-sprint
changeset 1147 402e8a8b1d6a
parent 1110 c71997f514ba
child 1152 c99ef2a2535c
equal deleted inserted replaced
1146:547681592765 1147:402e8a8b1d6a
   204         inputid = form.context[field]['id']
   204         inputid = form.context[field]['id']
   205         helperid = '%shelper' % inputid
   205         helperid = '%shelper' % inputid
   206         if not value:
   206         if not value:
   207             value = date.today()
   207             value = date.today()
   208         year, month = value.year, value.month
   208         year, month = value.year, value.month
   209         onclick = "toggleCalendar('%s', '%s', %s, %s);" % (
       
   210             helperid, inputid, year, month)
       
   211         return (u"""<a onclick="toggleCalendar('%s', '%s', %s, %s);" class="calhelper">
   209         return (u"""<a onclick="toggleCalendar('%s', '%s', %s, %s);" class="calhelper">
   212 <img src="%s" title="%s" alt="" /></a><div class="calpopup hidden" id="%s"></div>"""
   210 <img src="%s" title="%s" alt="" /></a><div class="calpopup hidden" id="%s"></div>"""
   213                 % (helperid, inputid, year, month,
   211                 % (helperid, inputid, year, month,
   214                    req.external_resource('CALENDAR_ICON'),
   212                    req.external_resource('CALENDAR_ICON'),
   215                    req._('calendar'), helperid) )
   213                    req._('calendar'), helperid) )
   224         if inputid is not None:
   222         if inputid is not None:
   225             self.attrs['cubicweb:inputid'] = inputid
   223             self.attrs['cubicweb:inputid'] = inputid
   226             
   224             
   227     def render(self, form, field):
   225     def render(self, form, field):
   228         self.add_media(form)
   226         self.add_media(form)
   229         name, values, attrs = self._render_attrs(form, field)
   227         attrs = self._render_attrs(form, field)[-1]
   230         return tags.div(**attrs)
   228         return tags.div(**attrs)