On a separate page, I edit the rest of these fields. Part of these
are check box fields and some others including textarea fields.
When I save the data on this page - all is well.
I then go back to the first page and make a change and save the data -
fine, but if I go back to the page with the check boxes, they are all
cleared out - I look in the DB in admin area and yes, they are all set
to False. But the textarea fields do not do this on this page - they
keep their data just fine.
So I created a test page and made a controller like I already have:
form=t2.create(db.student)
return dict(form=form)
and then in a test.html do {{=form}
I then save the page with a check box selected - fine - that works.
I then go back to my first page and make a change and save. Go back
to the test page and the check box is cleared.
Why is it doing this?
thx,
-wj
{{for cbi in range(26,27):}}
{{for cbi in range(26,76):}}
<input name="{{=form[0][cbi][1][0]['_name']}}" type=hidden
value="{{='true' if str(form[0][cbi][1][0]['_checked']) in 'checked'
else ''}}">
{{pass}}
It seems that there is no such think as a hidden checkbox, because:
<input name='this' type="hidden" value="checked">
when submitted does not keep its value, it gets set to unchecked when
saved. hmmm...
I will do some more testing, but for now this is what I have working.
On my first page I have:
<div id='hidethis'>
{{for cbi in range(26,76):}}
<input name="{{=form[0][cbi][1][0]['_name']}}" type=checkbox
{{='checked="checked"' if str(form[0][cbi][1][0]['_checked']) ==
'checked' else ''}}>
{{pass}}
</div>
I have hidden actual checkbox elements using css on the div
(#hidethis{display:none;}
The values are being kept now in all cases. For some reason, the only
way the checkboxes will keep their values between submits is if they
actually exist on a page.
I will make a simple example and post what i find.
thx for everyones input
-wes