Allow me simplify it, else I do not understand it:
def managetable():
(tablename, id) = (request.args(0), request.args(1)) # can be
None
response.view = "%s/%s.html" % (request.controller,
tablename)
return thefields(setsubmit(tablename))
# why not return dict(form=setsubmit(tablename)) ?
# this I do not understand
# if session.signon[session.searchfield]: managetable = eval
# (session.signon[session.searchfield]+"(managetable)")
def setsubmit(tablename,record=None):
if request.vars.submit1: command="create"
elif request.vars.submit2: command="read"
elif request.vars.submit3: command="update"
elif request.vars.submit4: command="delete"
return getattr(crud,command)(db[tablename],record)
def thefields(curform):
mydict(form=curform)
for fieldname in curform.record:
if fieldname in curform.custom.widget:
mydict[fieldname] = curform.custom.widget[fieldname]
return mydict
{{extend 'layout.html'}}
{{action = request.args(0)}}
<h1>location
{{if action == "update":}} Update
{{elif action == "create":}} Add
{{pass}}
</h1>
<form action="" enctype="multipart/form-data" method="post">
<table>
<tr id="location_poleno__row">
<td><label for="location_poleno" id="location_poleno__label">Poleno:
</label></td>
{{if action in ["update","create"]:}}
{{=" *** location_poleno"}}
{{else:}}
<td>{{=form.custom.widget.poleno}}</td>
{{pass}}
<td></td>
</tr>
<tr id="location_town_id__row">
> <td><label for="location_town_id" id="location_town_id__label">Town
Id: </label></td>
{{if action in ["update","create"]:}}
{{=" *** location_town_id"}}
{{else:}}
<!-- THIS IS THE LINE THAT SHOULD RETURN A SELECTED FIELD FROM A
SELECT TAG -->
<td>{{=form.custom.widget.town_id}}</td>
{{pass}}
<td></td>
</tr>
Does this work as expected? I do not underatnd it well enough to
debug. sorry.
Massimo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---