Odoo Website get multiple value of selection (multiple="multiple") or checkboxes
If you defined a selection on website form that will hold 'many2many' field, so it will look like 'many2many_tags' widget, you need a special handling on the controller backend.
By default, on the website form view you can select more than one value, but when you validated the form value sent to backend, it's only get the first value for this selection. Example code (xml):
<div id="group_permit" t-attf-class="form-group
<label class="col-md-3 col-sm-4 control-label" for="permit" >Driving License</label>
<div id="fields_permit" class="col-md-7 col-sm-8">
<select multiple="multiple" name="permit_id" class="form-control select2">
<t t-foreach="permit_ids" t-as="permit">
On the 'firebugs', you can see there are two value for selection field was sent to server, example:
But On the backend, when you debug the value was sent only detected the first value.
How to get all the value was selected?
We need extra code on the backend (controller) to handle it.
Example, when the form is submitted by POST method:
permit_ids = request.httprequest.form.getlist('permit_id')
or when it is by GET method:
permit_ids = request.httprequest.args.getlist('permit_id')
Then permit_ids will contain a list of selection or checkbox values.