Field('name',
      widget=lambda f, v: SQLFORM.widgets.string.widget(f, v, _placeholder='my 
placeholder text'))

Be sure to use the correct widget for the field type (i.e., string, text, 
etc.).

You could generalize with a special function:

def widget(type='string', placeholder=''):
    return lambda field, value: SQLFORM.widgets[type].widget(field, value, 
_placeholder=placeholder)

and then:

Field('name', widget=widget('string', 'my placeholder text'))

Anthony

On Friday, April 1, 2016 at 7:47:56 AM UTC-4, Nick Michael wrote:
>
> Hi there,
>
> I can't seem to find a way to add placeholder text using SQLFORM.factory.
>
> My table design is as follows:
>     upload_folder = os.getcwd() + "/applications/" + request.application 
> + "/uploads"
>     form = SQLFORM.factory(
>     Field('name', requires=db.user_items.name.requires),
>     Field('collection',  requires=IS_IN_SET([x['name'] for x in 
> db(db.collections.owner == auth.user).select(db.collections.name).as_list()], 
> zero=None)),
>     Field('tag', requires=db.user_items.tag.requires),
>     Field('value', 'float', label="Value (£)", 
> requires=db.user_items.value.requires),
>     Field('story', 'text', requires=db.user_items.story.requires),
>     Field('image', 'upload', uploadfolder=upload_folder, 
> requires=IS_EMPTY_OR(IS_IMAGE(extensions=('jpeg', 'png')))),
>     Field('tradeable', 'boolean', label="Add To Trade List")
>     )
>
> I've been able to do it using a regular form by using _placeholder but 
> this doesn't seem to work for a form factory. I couldn't find another topic 
> with this issue but I could be wrong.
>
> Thanks in advance
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to