249 self.add_localized_infos(form.req) |
249 self.add_localized_infos(form.req) |
250 cal_button = self._render_calendar_popup(form, field) |
250 cal_button = self._render_calendar_popup(form, field) |
251 return txtwidget + cal_button |
251 return txtwidget + cal_button |
252 |
252 |
253 def _render_calendar_popup(self, form, field): |
253 def _render_calendar_popup(self, form, field): |
254 req = form.req |
254 value = form.form_field_value(field) |
255 value = form.context[field]['rawvalue'] |
255 if not value: |
|
256 value = date.today() |
256 inputid = form.context[field]['id'] |
257 inputid = form.context[field]['id'] |
257 helperid = '%shelper' % inputid |
258 helperid = '%shelper' % inputid |
258 if not value: |
|
259 value = date.today() |
|
260 year, month = value.year, value.month |
259 year, month = value.year, value.month |
261 return (u"""<a onclick="toggleCalendar('%s', '%s', %s, %s);" class="calhelper"> |
260 return (u"""<a onclick="toggleCalendar('%s', '%s', %s, %s);" class="calhelper"> |
262 <img src="%s" title="%s" alt="" /></a><div class="calpopup hidden" id="%s"></div>""" |
261 <img src="%s" title="%s" alt="" /></a><div class="calpopup hidden" id="%s"></div>""" |
263 % (helperid, inputid, year, month, |
262 % (helperid, inputid, year, month, |
264 req.external_resource('CALENDAR_ICON'), |
263 form.req.external_resource('CALENDAR_ICON'), |
265 req._('calendar'), helperid) ) |
264 form.req._('calendar'), helperid) ) |
266 |
265 |
|
266 |
267 |
267 |
268 # ajax widgets ################################################################ |
268 # ajax widgets ################################################################ |
269 |
269 |
270 def init_ajax_attributes(attrs, wdgtype, loadtype=u'auto'): |
270 def init_ajax_attributes(attrs, wdgtype, loadtype=u'auto'): |
271 try: |
271 try: |