I consider Checkbox implementation is broken now, because
1. I can't create Checkbox without value like this:
from web import form
item_form = form.Form(form.Checkbox("chk"))
2. If I create form this way and try to validate it against the data
that has no value for the Checkbox:
from web import form
item_form = form.Form(form.Checkbox("chk", value="on"))
if item_form.validates(dict(abs="rr")):
print item_form.d
<Storage {'chk': "on"}>
Then item_form.d still has the value for "chk", but in case of
inserting item_form.d in database, it needs to be None if the Checkbox
wasn't checked. Well, it worked for me in the version before I did:
from web import form
item_form = form.Form(form.Checkbox("chk"))
if item_form.validates(dict(abs="rr")):
print item_form.d
<Storage {'chk': None}>
On Sep 13, 9:54 pm, andrei <[email protected]> wrote:
> And creating Checkbox without value doesn't work now.
>
> On Sep 13, 9:21 pm, andrei <[email protected]> wrote:
>
> > I would expect this to work:
>
> > all_name_values = [1,2,3,4,5]
>
> > checkboxes = []
> > for i in all_name_values:
> > checkboxes.append(form.Checkbox('names', value=i))
> > my_form = form.Form(*checkboxes)
>
> > my_values = web.input(names=[])
> > form_with_values = my_form(my_values)
>
> > And when calling form_with_values.render() I expect to see all
> > checkboxes with value in my_values to be checked.
> > I also would expect form_with_values.names and
> > form_with_values.d.names to return arrays.
>
> > On Sep 9, 12:57 pm, Anand Chitipothu <[email protected]> wrote:
>
> > > 2009/9/9 SeC <[email protected]>:
>
> > > >>>> web.form.Checkbox('checkbox1', value = 'test').render()
> > > > '<input type="checkbox" id="checkbox1" name="checkbox1"/>'
>
> > > > Still no 'value' attribute.
>
> > > Sorry, that was a mistake. Fixed now.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---