return tag('input', **attrs)


def autosuggest_extractor(widget, data):
    return data.extracted


factory.register('autosuggest',
                 extractors=[generic_extractor, autosuggest_extractor],
                 edit_renderers=[autosuggest_renderer])

factory.doc['blueprint']['autosuggest'] = \
"""Add-on blueprint `yafowil.widget.autosuggest
<http://github.com/conestack/yafowil.widget.autosuggest/>`_ utilizing
`jquery autosuggest <https://github.com/wuyuntao/jquery-autosuggest/>`_ to
offer the user a selection based on the input given so far.
"""

factory.defaults['autosuggest.class'] = 'autosuggest'
factory.defaults['autosuggest.type'] = 'text'
factory.defaults['autosuggest.required_class'] = 'required'
factory.defaults['autosuggest.delay'] = '300'  #ms
factory.defaults['autosuggest.minLength'] = '1'  #characters
factory.defaults['autosuggest.disabled'] = False
factory.defaults['autosuggest.size'] = None
factory.defaults['autosuggest.source'] = None
factory.defaults['autosuggest.autocomplete'] = 'autocomplete'

factory.register_plan('autosuggestfield',
                      ['field', 'label', 'error', 'autosuggest'], {})

def autosuggest_extractor(widget, data):
    return data.extracted


factory.register(
    'autosuggest',
    extractors=[generic_extractor, autosuggest_extractor],
    edit_renderers=[autosuggest_renderer])

factory.doc['blueprint']['autosuggest'] = \
"""Add-on blueprint `yafowil.widget.autosuggest
<http://github.com/bluedynamics/yafowil.widget.autosuggest/>`_ utilizing
`jquery autosuggest <https://github.com/wuyuntao/jquery-autosuggest/>`_ to
offer the user a selection based on the input given so far.
"""

factory.defaults['autosuggest.class'] = 'autosuggest'
factory.defaults['autosuggest.type'] = 'text'
factory.defaults['autosuggest.required_class'] = 'required'
factory.defaults['autosuggest.delay'] = '300' #ms
factory.defaults['autosuggest.minLength'] = '1' #characters
factory.defaults['autosuggest.disabled'] = False
factory.defaults['autosuggest.size'] = None
factory.defaults['autosuggest.source'] = None
factory.defaults['autosuggest.autocomplete'] = 'autocomplete'

factory.register_plan('autosuggestfield',
                      ['field', 'label', 'error', 'autosuggest'], {})
Esempio n. 3
0
from yafowil.base import factory

_PLANS = (
    ('stringfield',     ['field', 'label', 'error', 'text']),
    ('numberfield',     ['field', 'label', 'error', 'number']),
    ('emailfield',      ['field', 'label', 'error', 'email']),
    ('urlfield',        ['field', 'label', 'error', 'url']),
    ('passwordfield',   ['field', 'label', 'error', 'password']),
    ('textfield',       ['field', 'label', 'error', 'textarea']),
    ('selectionfield',  ['field', 'label', 'error', 'selection']),
    ('submitfield',     ['field', 'submit']),
)

for name, blueprints in _PLANS:
    factory.register_plan(name, blueprints)