i am not able to save multiple selections in field. only saving first selection.
requirement: i wanna select multiple selections
please check my xml code and my controller
<div t-if="user_id.sudo().is_student" class="row mt8 col-md-12">
<div class="col-md-2 mt8">
<lable for="elective_subject_ids">Elective Subjects:</lable>
</div>
<div class="col-md-10" style="padding-left: 5px;">
<select class="form-control js_select2" name="elective_subject_ids" multiple="True"
required="1">
<t t-foreach="subjects" t-as="subject">
<t t-if="subject.subject_type == 'elective'">
<option t-attf-value="subject.id">
<t t-esc="subject.name"/>
</option>
</t>
</t>
</select>
</div>
</div>
controller.py@http.route('/subject/registration/submit', type='http', auth='public', website=True)
def portal_student_subject_registration_data(self, **kw):
subject_register_ids = request.env['op.subject.registration'].sudo().create(kw)
elective_subject_ids = request.httprequest.form.getlist('elective_subject_ids')
for obj in subject_register_ids:
obj.state = 'submitted'
obj.elective_subject_ids = elective_subject_ids
return request.render("portal_student.portal_student_subject_registration_data",
{'subject_register_ids': subject_register_ids})