I don't know if it could be difficult to implement it... I know that I need more js and jQuery knowledge to do it myself... I'd like to write a custom text widget that when I introduce a blank space after a word (supposed to be a name of a city, country, etc.) it uses the geocode function to suggest in other input fields the resulting longitude and latitude values.

Maybe we can start from a StringWidget as can be cut&paste from sqlhtml.py in gluon. Let's rename it with...

class SuggestLatLonWidget(FormWidget):
    _class = 'string'

# we need an init function to store in the class the name of the two field that will get the lat and lon values

    def __init__(self, lat_field_name, lon_field_name):
        self.lat_field_name = lat_field_name
        self.lon_field_name = lon_field_name

    @classmethod
    def widget(cls, field, value, **attributes):
        """
        generates an INPUT text tag.

        see also: :meth:`FormWidget.widget`
        """

        default = dict(
            _type = 'text',
            value = (not value is None and str(value)) or '',
            )
        attr = cls._attributes(field, default, **attributes)

        return INPUT(**attr)

is there somebody interested to help me with it? Maybe we could work together to a recipe on web2py[:] to start...

thank a lot

cheers

    Manuele

Reply via email to