thanks.

feels right to have this data in the view but I can see the advantage
of 'declare once' in the model.
I agree Anthony, a solution could be baked into web2py as 'label'
already has been. html5 is here and adoption is pretty good thanks in
large part to webkit.

On 23 June 2011 17:04, Anthony <abasta...@gmail.com> wrote:
> 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 <m....@carlroach.com> 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