Rendering SQLFORMs with a custom template, any hidden fields I create, as well
as the hidden ID field are not displayed in the form until a call to accepts.
I think this might be a bug because the same form rendered without a custom
template will have the ID and hidden fields without calling accepts.
I tested against latest release.
Thoughts?
Sample controller action:
def index():
form = SQLFORM(db.images, db.images(1),
hidden=dict(test_field="test_value"))
accepted_form = SQLFORM(db.images, db.images(1),
hidden=dict(test_field="test_value"))
accepted_form.accepts(request.vars, formname=None)
return dict(form=form, accepted_form=accepted_form)
Sample view:
<!-- RENDER WITHOUT A TEMPLATE -->
{{=form}}
<!-- RENDER WITH A TEMPLATE -->
{{=form.custom.begin}}
Image name: <div>{{=form.custom.widget.name}}</div>
Image file: <div>{{=form.custom.widget.file}}</div>
Click here to upload: {{=form.custom.submit}}
{{=form.custom.end}}
<!-- RENDER WITH TEMPLATE AFTER ACCEPTS -->
{{form=accepted_form}}
{{=form.custom.begin}}
Image name: <div>{{=form.custom.widget.name}}</div>
Image file: <div>{{=form.custom.widget.file}}</div>
Click here to upload: {{=form.custom.submit}}
{{=form.custom.end}}
Sample output:
<!-- RENDER WITHOUT A TEMPLATE -->
<form action="" enctype="multipart/form-data" method="post"><table><tr
id="images_id__row"><td class="w2p_fl"><label for="images_id"
id="images_id__label">Id: </label></td><td class="w2p_fw"><span
id="images_id">1</span></td><td class="w2p_fc"></td></tr><tr
id="images_name__row"><td class="w2p_fl"><label for="images_name"
id="images_name__label">Name: </label></td><td class="w2p_fw"><input
class="string" id="images_name" name="name" type="text" value="a" /></td><td
class="w2p_fc"></td></tr><tr id="images_file__row"><td class="w2p_fl"><label
for="images_file" id="images_file__label">File: </label></td><td
class="w2p_fw"><input class="upload" id="images_file" name="file" type="file"
/></td><td class="w2p_fc"></td></tr><tr id="submit_record__row"><td
class="w2p_fl"></td><td class="w2p_fw"><input type="submit" value="Submit"
/></td><td class="w2p_fc"></td></tr></table><div class="hidden"><input
name="test_field" type="hidden" value="test_value" /><input name="id"
type="hidden" value="1" /></div></form>
<!-- RENDER WITH A TEMPLATE -->
<form action="" enctype="multipart/form-data" method="post">
Image name: <div><input class="string" id="images_name" name="name" type="text"
value="a" /></div>
Image file: <div><input class="upload" id="images_file" name="file" type="file"
/></div>
Click here to upload: <input type="submit" value="Submit" />
</form>
<!-- RENDER WITH TEMPLATE AFTER ACCEPTS -->
<form action="" enctype="multipart/form-data" method="post">
Image name: <div><input class="string" id="images_name" name="name" type="text"
value="" /><div class="error" id="name__error">enter from 10 to 255
characters</div></div>
Image file: <div><input class="upload" id="images_file" name="file" type="file"
/></div>
Click here to upload: <input type="submit" value="Submit" />
<div class="hidden"><input name="test_field" type="hidden" value="test_value"
/><input name="id" type="hidden" value="1" /></div></form>
This communication, including any attachments, does not necessarily represent
official policy of Seccuris Inc.
Please see http://www.seccuris.com/Contact-PrivacyPolicy.htm for further
details about Seccuris Inc.'s Privacy Policy.
If you have received this communication in error, please notify Seccuris Inc.
at [email protected] or at 1-866-644-8442.