That's :

           for f in db[request.args(0)].fields:
                if db[request.args(0)][f].type == 'text':
                    db[request.args(0)][f].widget = lambda field, value:
SQLFORM.widgets.text.widget(field, value, _placeholder='test123')

Richard

On Mon, Sep 17, 2012 at 2:22 PM, Richard Vézina <ml.richard.vez...@gmail.com
> wrote:

> Maybe the proper way to append attributes to field is by widget as Anthony
> wrote here :
> http://stackoverflow.com/questions/8661166/custom-css-classes-for-sqlform-widget-input-in-web2py/8661906#8661906
>
> From this thread :
> https://groups.google.com/forum/?fromgroups=#!topic/web2py/c-0EMp26uDc
>
> Richard
>
>
> On Mon, Sep 17, 2012 at 1:53 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Right!
>>
>> I have a questioning about placeholder attribute. I don't know what the
>> plans about integration of html5 into web2py (since placeholder is a new
>> attribute of input in html5), but the only place where it makes sens to set
>> the placeholder value is at the field definition in the model I think. I
>> don't know if it makes sens to have html attributes there. One thing for
>> sure is that having placeholder support in web2py, would limit the overhead
>> of modifying the form once it created.
>>
>> Richard
>>
>>
>> On Wed, Sep 12, 2012 at 2:26 PM, Anthony <abasta...@gmail.com> wrote:
>>
>>> It should be 'input[type=text]' instead of "input[type='text']" (i.e.,
>>> no quotes around "text" when using that syntax).
>>>
>>> Anthony
>>>
>>>
>>> On Wednesday, September 12, 2012 1:59:57 PM UTC-4, Richard wrote:
>>>
>>>> I will try, but Bruno's code was :
>>>>
>>>> for input in form.elements("input[type='tex**t']"):
>>>>     input["_placeholder"] = placeholders.get(input["_name"**], "")
>>>>
>>>> And it didn't catch anything...
>>>>
>>>> input[] return all the input...
>>>>
>>>> Anyway, I try and I report.
>>>>
>>>> Richard
>>>>
>>>> On Wed, Sep 12, 2012 at 1:11 AM, Anthony <abas...@gmail.com> wrote:
>>>>
>>>>> The proper code I come up with :
>>>>>>
>>>>>> {{{
>>>>>>             for input_elem in form.elements("input[]"):
>>>>>>                 if input_elem.attributes['_type']****=='text':
>>>>>>                         input_elem["_placeholder"] =
>>>>>> YOURPLACEHOLDERTEXT
>>>>>> }}}
>>>>>>
>>>>>>
>>>>> Why not just form.elements('input[type=**text]') or form.elements('input',
>>>>> _type='text')?
>>>>>
>>>>> Anthony
>>>>>
>>>>> --
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>  --
>>>
>>>
>>>
>>>
>>
>>
>

-- 



Reply via email to