Extend SQLFORM.factory with two fields.

38 views
Skip to first unread message

annet

unread,
Aug 12, 2011, 3:42:16 AM8/12/11
to web2py-users
In a custom registration function I have the following form:

form=SQLFORM.factory(db.auth_user,ignore_rw=True)

for administrative reasons I want to extend the form with the
following fields:

Field('comment',type='text')
Field('mail',type='boolean',default=False)

The fields aren't stored in the auth_user table, when mail is True the
register function will, after the registration process was successful
redirect to a mail function in order for the administrator to reply to
the comment.

How do I extend the form this way.


Kind regards,

Annet.

Massimo Di Pierro

unread,
Aug 12, 2011, 6:43:20 AM8/12/11
to web2py-users
Why not do

auth.settings.extra_field['auth_user']=[
Field('comment',type='text'),
Field('mail',type='boolean',default=False)
]

and just use

SQLFORM(db.auth_user)

annet

unread,
Aug 12, 2011, 11:08:39 AM8/12/11
to web2py-users
> Why not do
>
> auth.settings.extra_field['auth_user']=[
>   Field('comment',type='text'),
>   Field('mail',type='boolean',default=False)
> ]

Because I have a registration form which users can use to register for
a service and to up- or downgrade their account. If they enter a
comment which requires a reply, the administrator should be able to
check mail True, in which case comment will be the start of a mail
thread in another table.

> and just use
>
> SQLFORM(db.auth_user)

I need if form.accepts(request.vars,session):, because I have to
insert/update data in multiple tables after the form has been
accepted.


Kind regards,

Annet.
Reply all
Reply to author
Forward
0 new messages