I've been trying and failing with trying to get that to work with the form wizard, it works without it.
The conditional fields just don't work at all, the form proceeds as normal showing every field in every step. I don't know if I am just placing things in the wrong place or what.
step = int(request.args(0) or 0)
if not step in STEPS: redirect(URL(args=0))
fields = STEPS[step]
if step == 0:
d = 'General Information'
session.myform = {}
if step == 1:
d = 'Day 1'
if step == 2:
d = 'Day 2'
if step == 3:
d = 'Day 3'
if isinstance(fields,tuple):
db.myform.field2.show_if = (db.myform.field1==True) form = SQLFORM.factory(*[f for f in db.myform if
f.name in fields])
if form.accepts(request,session):
session.myform.update(form.vars)
redirect(URL(args=step+1))
else:
db.myform.insert(**session.myform)
session.flash = T('form completed')
redirect(fields)
return dict(form=form,step=step, d=d)
And then with and without numerous variations:
<script>
jQuery(document).ready(function(){
if(jQuery('#myform_field1').prop('checked'))
jQuery('#myform_field2__row').show();
else jQuery('#myform_field2__row').hide();
jQuery('#myform_field1').change(function(){
if(jQuery('#myform_field1').prop('checked'))
jQuery('#myform_field2__row').show();
else jQuery('#myform_field2__row').hide();});
});
</script>
It does absolutely nothing no matter how I try implementing it with the form wizard.