I've been trying to make a form with checkboxes and radio button using Pyramid framework but I can't figure out how to do it properly.
I'm using the pyramid_simpleform
. So far I've been able to put my checkboxes on the form using a for loop but I can't make any checkbox checked even if I specify checked=True
.
% for item in groups:
${form.checkbox(name="groups",label=item, value=item, checked=True)}
% endfor
I know there's a better way of doing this. Is there any examples I could look at. All the examples in pyramid's documentation are simple text fields. I didn't find any radio button or checkboxes so far.
Have you tried put
defaults={"groups" : True}
in Form ctor, for example (in pyramid_simpleform doc):
form = Form(request, MySchema, defaults={"name" : "foo"})
I use FormRenderers to output forms and also had problems using Checkboxes. So I wrote the following class that replaces the FormRenderer from simple_form in all my views: