Sorry for being so long winded.
I've been trying to implement a custom html form using the crud
applications as explained above, but I'm having difficulty using
custom html. Here is the test MVC that I've created for the purpose
of understanding the concepts:
Model
--------
try:
from gluon.contrib.gql import * # if running on Google App Engine
except:
db = SQLDB('sqlite://storage.db') # if not, use SQLite or other
DB
else:
db = GQLDB() # connect to Google BigTable
session.connect(request, response, db=db) # and store sessions
there
##
db.define_table('testtable',SQLField('testfield1','string'),SQLField
('testfield2','string'))
from gluon.tools import Mail, Auth, Crud # new in web2py 1.56
crud=Crud(globals(),db) # for CRUD helpers using
auth
crud.settings.update_next = URL(r=request, f='index')
=====
Controller
------------
def index():
redirect(URL(r=request,f='testupdate',args=["1"]))
def testupdate():
id=request.args[0]
return dict(form=crud.update(db.testtable,id))
def data():
response.view="%s/%s/%s.html" %
(request.controller,request.function, request.args[0])
return dict(form=crud())
=======
View (default/testupdate.html)
{{extend 'layout.html'}}
<h1>This is the default/testupdate.html template</h1>
<!-- Try the form (Works)-->
{{=form}}
<!--Try individual form fields (Submit doesn't work)-->
{{for field in form:}}
{{=field}}
{{pass}}
<!-- Try the form by duplicating form output (Submit doesn't work)-->
<table>
<tr id="testtable_testfield1__row">
<td><label for="testtable_testfield1"
id="testtable_testfield1__label">Testfield1: </label></td>
<td><input class="string" id="testtable_testfield1"
name="testfield1" type="text" value="testdata1" /></td>
<td></td>
</tr>
<tr id="testtable_testfield2__row">
<td><label for="testtable_testfield2"
id="testtable_testfield2__label">Testfield2: </label></td>
<td><input class="string" id="testtable_testfield2"
name="testfield2" type="text" value="testdata2" /></td>
<td></td>
</tr>
<tr id="delete_record__row">
<td><label for="delete_record" id="delete_record__label">Check to
delete:</label></td>
<td><input class="delete" id="delete_record"
name="delete_this_record" type="checkbox" value="on" /></td>
<td></td></tr><tr id="submit_record__row"><td></td><td><input
type="submit" value="Submit" /></td>
<td></td>
</tr>
</table>
<div class="hidden"><input name="_next" type="hidden" value="http://
localhost:8001/test/default/testupdate/1" />
<input name="id" type="hidden" value="1" />
<input name="_formkey" type="hidden" value="b7418550-1b4a-434b-
bdc1-84a24e904582" />
<input name="_formname" type="hidden" value="testtable_1" />
</div>
</form>
========
It's obvious that the hidden field 'formname' is required and changes
with each submission. I assume that there is a value that can be
inserted there to fix that problem, but is this the best/only way to
gain full control of the display of a crud application? Any insight
will be greatly appreciated.
Thanks,
Gary
====================================================================
====================================================================