pyramid checkboxes

Viewed 1684

I'm just new to python and pyramid and I'm struggling with how to process the results of a form containing multiple checkboxes in Pyramid.

Here is an excerpt from my form:

<p tal:repeat="category categories">
    <input type="checkbox" name="selectedcategories" value="${category.id}"> ${category.name}<br/>
</p>

And here is how I am currently trying to iterate through and process the results:

selectedcategories=request.params['selectedcategories']    
for categoryid in selectedcategories:
        category = DBSession.query(Category).filter_by(id=categoryid).one()
        article.categories.append(category)

As you may have guessed, I'm only getting a maximum of one checkbox recognized no matter how many I select on the form. Django has an option to return the results as a list, but I can't seem to figure out how to do that with Pyramid.

1 Answers
Related