Hi Steve,
Erm, I'm not sure, I'm manually updating each field after verification
so I guess you can update whatever you like there, I'm pretty new to
this though so apologies if I'm missing your point! One of the issues
that arises when trying to do this, as Massimo correctly predicted
above, is the namespace clash when you have the same field name in
multiple tables. I guess the way to deal with that is to prepend the
table name onto the html input's name but for the time being I've just
made sure all the field names I might need to stick in a form are
unique in my model.
I agree, generating significant html in the controller is something to
be avoided longterm, ideally the controller would just pass all the
constituent parts up to the view. I'm pretty new to web2py but I
gather for a controller to be able to understand the returned values
from a form the form has to be generated in that controller as it also
generates other stuff like a nonce that it needs to matchup again
after submission.
I think the thing to do is to have a function just like form_factory
except that it would return a dictionary of constituent parts rather
than raw html. Something like...
return { '_labels' : [ ('Enter Name','contact_name'),
('Enter Email','email_address') ],
'email_address' : '<input class="string"
id="no_table_email_address" name="email_address" type="text" value="" /
>',
'contact_name' : '<input class="string"
id="no_table_contact_name" name="contact_name" type="text" value="" /
>',
'_form_start' : '<form action="" enctype="multipart/
form-data" method="post">',
'_form_end' : '<input name="_formkey" type="hidden"
value="afae447e-fb27-4bd1-b89c-d5bb6c130401" /></form>' }
So you could write something like this in the view...
{{ =form_bits['_form_start'] }}
Please enter a name: {{=form_bits["contact_name"]}}<br>
And an Email: {{=form_bits["email_address"]}}<br>
{{ =form_bits['_form_end'] }}
Or iterate through the "_labels" list and generate it
programatically.
I might have a look at the code later, see if it would be practical.
The promise of autogenerated autoverified forms was one of the things
that attracted me to web2py but there's no way I can use it longterm
if it's going to insist on embedding them in tables!
:)
Roger.
On Apr 5, 5:38 am, Steve Shepherd <[email protected]> wrote:
> @Roger
>
> Does this address any hidden fields you may want updating. ie modified date,
> modfied by, ID?
>
> I like where your going...
>
> The only problem I have with this area is we are putting visual UI into
> controllers.
> The MVC model is supposed to put UI in the V portion.
>
> However web2py seems to be moving more and more to constructing view
> elements in the controllers are with simple placement formating being
> defined in the views...
> Just my ramblings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---