Thanks a lot !
On Dec 12, 11:34 pm, Bruno Rocha <
rochacbr...@gmail.com> wrote:
> Sorry, my fault, SQLFORM.factory generates forms based on tables, but this
> does not make the inserts automatically.
>
> if you want to use that to include extra fields in a form it is a good
> choice, but you'll need to implement the 'inserts' for the table.
>
> orm=SQLFORM <
http://web2py.com/book/default/docstring/SQLFORM>.factory(db.client,Field('extra_field'))
> if form.accepts(request
> <
http://web2py.com/book/default/docstring/request>.vars):
> id = db.client.insert(**db.client._filter_fields(form.vars))
> form.vars.client=id
> response
> <
http://web2py.com/book/default/docstring/response>.flash='Thanks for
> filling the form'
> return dict(form=form)
>
> The advantage here is that you can set validators to the extra fields.
>
> *Look this example in a shell:*
>
> >>> form = SQLFORM.factory(db.category,Field('new_field'))
> >>> print form
>
> <form action="" enctype="multipart/form-data" method="post"><table><tr
> id="no_table_name__row"><td class="w2p_fl"><label for="no_table_name"
> id="no_table_name__label">Name: </label></td><td class="w2p_fw"><input
> class="string" id="no_table_name" name="name" type="text" value=""
> /></td><td class="w2p_fc"></td></tr><tr id="no_table_new_field__row"><td
> class="w2p_fl"><label for="no_table_new_field"
> id="no_table_new_field__label">New Field: </label></td><td class="w2p_fw"><i
> *nput class="string" id="no_table_new_field" name="new_field" type="text"
> value="" />*</td><td class="w2p_fc"></td></tr><tr