Open eventoul opened 4 months ago
Hi!
I have an issue with the code below:
`
<tr th:each="course : ${department.courses}"> <th th:text="${course.id}"></th> <th th:text="${course.title}"></th> <th th:text="${course.mandatory}"></th> <th th:text="${course.duration}"></th> <th th:text="${course.credits}"></th> <th> <div class="form-check"> <label class="form-check-label" for="checkboxCourses"></label> <input id="checkboxCourses" type="checkbox" class="form-check-input" th:value="${course.id}" th:field="*{courses}" th:checked="${course.mandatory}" /> </div> </th> </tr> </tbody>`
I want the checkbox to be checked when a course is mandatory.
The th:field="*{courses}" refers to a Student model, which has a many-to-many relationship with the Course model.
th:field="*{courses}"
I noticed that the th:checked="${course.mandatory}" works when I didn't have the th:field, but then I can't bind the course.id to save it in DB.
th:checked="${course.mandatory}"
th:field
Any ideas?
PS: I want to be checked and disabled.
yap @eventoul
I have the same issue but I manage it using the following
<input id="checkboxCourses" type="checkbox" class="form-check-input" th:value="${course.id}" name="courses" th:checked="${course.mandatory}" />
There is an assumption that course.mandatory variable value is "selected"
Hi!
I have an issue with the code below:
`
I want the checkbox to be checked when a course is mandatory.
The
th:field="*{courses}"
refers to a Student model, which has a many-to-many relationship with the Course model.I noticed that the
th:checked="${course.mandatory}"
works when I didn't have theth:field
, but then I can't bind the course.id to save it in DB.Any ideas?
PS: I want to be checked and disabled.
yap @eventoul
I have the same issue but I manage it using the following
There is an assumption that course.mandatory variable value is "selected"