SQLFORM factory

28 views
Skip to first unread message

Arvind

unread,
Sep 22, 2009, 1:36:22 AM9/22/09
to web2py-users
Hello,


I find that the SQLFORM factory name somewhat leads me to believe
that, this is a form factory based off sql. WHy such a name for a
factory which does not actually use SQL ?


I need to build forms, which contains fields from different tables.
The form fields will be placed on specific places on the screen to
create a different visual effect.
Which kind of FORM creation method is best suited for this kind of
work ?


pls forgive me, if i am asking very basic questions. I have worked
nearly all my life with ASP.NET and I am still finding it hard to
understand certain concepts here. Especially, when it comes to
designing your own custom looking forms with different attributes and
behaviours. For me, i see that the whole form is being creating in the
controller as opposed to the view. So, i am taking a while to digest
web2py's way of doing things.

thanks
Arvind

DenesL

unread,
Sep 22, 2009, 6:31:08 AM9/22/09
to web2py-users
Hi Arvind,

On Sep 22, 12:36 am, Arvind <arvind.ran...@gmail.com> wrote:
> Hello,
>
> I find that the SQLFORM factory name somewhat leads me to believe
> that, this is a form factory based off sql. WHy such a name for a
> factory which does not actually use SQL ?

It does use SQL to CRUD data from the table during accepts processing.

> I need to build  forms, which contains fields from different tables.
> The form fields will be placed on specific places on the screen to
> create a different visual effect.
> Which kind of FORM creation method is best suited for this kind of
> work ?

SQLFORM can be used with one table at a time.
But you can have multiple forms per page and <mind-opener-follows> you
don't have to display the form or forms as created by SQLFORM, you
don't even have to pass them to the view (in case of input only), you
can have your own forms as long as they name the fields the same.
See manual:
page 188 (204 in ipaper): "Multiple forms per page",
page 218 (234 in ipaper): section 7.7 "Custom form".

> pls forgive me, if i am asking very basic questions. I have worked
> nearly all my life with ASP.NET and I am still finding it hard to
> understand certain concepts here. Especially, when it comes to
> designing your own custom looking forms with different attributes and
> behaviours. For me, i see that the whole form is being creating in the
> controller as opposed to the view.  So, i am taking a while to digest
> web2py's way of doing things.

You can create the form in the controller or you create it completely
outside web2py.
Now that is flexibility.

Denes.

waTR

unread,
Sep 23, 2009, 11:47:56 AM9/23/09
to web2py-users
Alternitively, if you really want to be crazy, you could do it just
like in PHP:
http://pastebin.com/d5b147192

In controller, you can get the values you submitted using either
request.vars.get('fieldname', '') OR request.get_vars. If you use
'post' method, replace 'get' with 'post'. Easy eh? Get the cheet sheet
for some useful function/method call names you will use often:
http://www.web2py.com/examples/static/web2py_cheatsheet.pdf

Not sure how to collect form errors using this method though... :( I
hope it is still possible... can someone comment on this?
Reply all
Reply to author
Forward
0 new messages