A couple other methods:
 
1. In the controller or view:
 
form.custom.widget.first_name.update(_placeholder="first name")
 
or
 
2. Customize the db.yourtable.first_name widget:
 
db.define_table('yourtable', Field('first_name',
    widget=lambda field,value: SQLFORM.widgets.string.widget(field, value, 
_placeholder='first name')),
    [rest of table definition])
 
or specify it after table definition via 
db.yourtable.first_name.widget=lambda...
 
Method #2 will apply the change to all forms that include that field.
 
There should probably be an easier/more straightforward way to do this, 
though. All the widgets take keyword arguments, but it doesn't look like 
there's an easy way to pass them in when the widgets are associated with db 
table fields.
 
Anthony
 

On Thursday, June 23, 2011 10:55:19 AM UTC-4, Massimo Di Pierro wrote:

> form.element(_id='...')['_placeholder']='...' 
>
> On Jun 23, 9:24 am, Carl <[email protected]> wrote: 
> > I'm using custom forms in my views using this format: 
> > {{=form.custom.widget.first_name}} 
> > 
> > I'd like to use HTML's placeholder attribute to input tags: e.g., 
> > <input type="text" placeholder="first name" /> 
> > 
> > Today: what are the ways to enable this? Obviously happy to drop the 
> > {{=form.custom.widget.first_name}} format and use something else. 
> > 
> > Tomorrow: might it be a good idea to add placeholder attribute to 
> > db.Field() in a similar fashion to how 'label' has already been added?

Reply via email to