Hi Leonel and all, (first post here) Don't know if I'm reinveinting the wheel, but I was searching for a better datepicker and found your plugin. And liked so much that I modified it to make it work with a datepicker fork -> https://github.com/eternicode/bootstrap-datepicker
To me works fine so I'm posting the code here for you to have a look at. Why aren't everybody using this? Anyway thanks a lot! P.S. How do we arrange for the beer? :) # -*- coding: utf-8 -*- """ Integrates bootstrap-datepicker nicely into web2py. Download the plugin at: https://github.com/eternicode/bootstrap-datepicker """ __author__ = 'Leonel Câmara' __email__ = '' __copyright__ = 'Copyright(c) 2014 Leonel Câmara' __license__ = 'BEER-WARE' __version__ = '0.12' __status__ = 'Development' # possible options: Prototype, Development, Production from gluon import * from gluon.sqlhtml import FormWidget def bsdatepicker_widget(**settings): """ Usage: from plugin_bs_datepicker import bsdatepicker_widget db.table.field.widget = bsdatepicker_widget() Examples: ## notice double quotes wrapping string parameters. db.table.field.widget = bsdatepicker_widget( startView=2, startDate="'-200y'", endDate="'0y'") ## pass a language code this way: langcode = 'it' db.table.field.widget = bsdatepicker_widget( language="'{0}'".format(langcode)) look at: http://bootstrap-datepicker.readthedocs.org/en/stable/options.html for settings full list. """ def widget(field, value, **attributes): default = {'value': value} attributes = FormWidget._attributes(field, default, **attributes) attributes['_class'] = 'form-control datepicker' dateinput = INPUT(**attributes) ## if language 'en' (default) remove setting, don't append locale script. locale = '' lang = settings.get('language', None) if lang == "'en'": del(settings['language']) elif lang: url = URL('static', 'plugin_bs_datepicker/locales/' \ 'bootstrap-datepicker.{lang}.min.js'.format(lang=lang[1:-1 ])) locale = "$('body').append($('<script src=\"{url}\"></script>'));".format(url=url) settings_str = ',\n'.join(item[0] + ':' + str(item[1]) for item in settings.iteritems()) if settings else '' javascript = SCRIPT( """ $('head').append($('<link href="%(css_url)s" type="text/css" rel="stylesheet" />')); $.getScript('%(js_url)s').done(function(){ %(locale_script)s $('#%(_id)s').datepicker({ format: w2p_ajax_date_format.replace('%%Y', 'yyyy'). replace('%%m', 'mm').replace('%%d', 'dd'), %(settings)s }) }); """ % { 'css_url': URL('static', 'plugin_bs_datepicker/css/bootstrap-datepicker.css'), 'js_url': URL('static', 'plugin_bs_datepicker/js/bootstrap-datepicker.js'), 'locale_script': locale, '_id': dateinput.attributes['_id'], 'settings': settings_str }) return CAT(dateinput, javascript) return widget -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

