The "represent" attribute only affects how the values are displayed in 
particular contexts, not what goes in the database. To transform values 
before inserting into the db, you can create a custom validator that simply 
transforms the value but never returns an error (that's what validators 
like CRYPT and SLUG do). If you want the transformation to affect all 
inserts (not just forms or occasions when .validate_and_insert are called), 
you can also specify a "filter_in" attribute for the field.

Anthony

On Friday, April 18, 2014 11:23:41 AM UTC-4, [email protected] wrote:

> Hello.
>
> Im trying to preprocess SQLFORM fields before they are saved into the 
> database, for example given a table like 
> the model:
> db.define_table("people",
>    Field('first_name', 'string'),
>    Field('last_name', 'string')
> )
>
> I want to capitalize first and last name before they are saved into the 
> database. Its not validation what im looking for but process specific 
> fields as i like.
>
> Ive tried:
> db.people.first_name.represent = str.capitalize 
> db.people.last_name.represent = str.capitalize
> but doesnt seem to do anything.
>
> the controller:
> def index():
>     form = SQLFORM(db.people)
>     if form.process().accepted:
>         message = "Updated" 
>     return locals()
>
> Thanks.
>

-- 
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.

Reply via email to