On Monday, July 25, 2016 at 2:25:32 PM UTC-7, [email protected] wrote:
>
> I have the same question. But for DAL in general. How to limit the string
> or text?
>
Field('myfield', 'string', length=32, ...)
This is described in the Field constructor documentation, but I'm not sure
there are any examples in the book using this.
<URL:http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Field>
/dps
>
> On Monday, July 25, 2016 at 5:00:49 PM UTC-4, icodk wrote:
>>
>> How can I change the input field size (what is visible to the user) of
>> SQLFORM.grid auto generated Edit/New forms.
>> Tried with length=50 but the fields are still about 20 chars long.
>> Also: IS_LENGTH(minsize=5,maxsize=50) had no visible effect. None of
>> the settings limits the number of chars user can type in. Only when
>> submitting the form you get an error message. But this might be
>> the intended design.
>>
>>
This seems to work:
form.custom.widget.ftest1['_maxlength'] = 14
(I tested this on a string field)
You can also use a lambda to instruct your widget in the Field()
constructor.
My research found Anthony's post from a year ago March:
<URL:https://groups.google.com/d/msg/web2py/7KNT72mOTYg/v8takmfGZQgJ>
"maxlength" is a standard HTML attribute, and SQLFORM respects that. It
should apply to the string, text, password, and maybe also to the integer
and double/decimal fields. The validators in the model file will only be
applied on submission, I believe. Adjusting the size of the input box
involves a separate attribute, which would be '_size', but that doesn't
seem to work unless you specify the formstyle explicitly; it works with
either 'table2cols' or 'table3cols' in my quick tests.
/dps
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.