I am trying to submit this form with val2 and val3 checked.
<form name="main" method="post">
<input id="chk_1" value="val1" name="chk[]" type="checkbox" />
<input id="chk_2" value="val2" name="chk[]" type="checkbox" />
<input id="chk_3" value="val3" name="chk[]" type="checkbox" />
<input id="chk_4" value="val4" name="chk[]" type="checkbox" />
<input id="chk_5" value="val5" name="chk[]" type="checkbox" />
<input type="submit"/>
</form>
If i pprint rawinput() result, i will get the desired:
<Storage {'chk[]': ['val2', 'val3']}>
But web.input() returns web.storify() of it:
<Storage {'chk[]': u'val3'}>
Maybe we should fix it somehow?
And the next step would be creating CheckboxList in Form.
Found the solution — passing chk=[] to web.input.
pprint(web.input(chk=[]))
<Storage {'chk': [u'val1', u'val3']}>
It looks good except for the following:
* There is no way to add class/id to individual checkboxes.
* form should be able to figure out that it should expect multiple
values and shouldn't have to depend on user giving the input.
form = myform() should work even with CheckboxList. I have been
postponing its implementation just because of this reason.
As for the second one, I'm not quite sure what you mean. Does it mean
that it requires passing additional "chk=[]" to web.input()?
On Dec 24, 12:57 pm, Anand Chitipothu <anandol...@gmail.com> wrote:
> On Thu, Dec 24, 2009 at 3:14 PM, andrei <andre...@gmail.com> wrote:
> > I implemented CheckboxList form elementhttp://pastie.org/755516.
See, it is getting complicated.
> As for the second one, I'm not quite sure what you mean. Does it mean
> that it requires passing additional "chk=[]" to web.input()?
Yes.
form = myform() shouldn't raise exception.
On Dec 24, 1:32 pm, Anand Chitipothu <anandol...@gmail.com> wrote: