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) |