I have a list of objects in my view:
<tbody>
<tr th:each="object : ${myObjects}">
<td><span th:text="${object.id}"> </span></td>
<td><span th:text="${object.name}"> </span></td>
<td><span th:text="${object.address}"></span></td>
<td>
<a href="#" data-toggle="modal" data-target="#ADD_SOME_INFO_MODAL">
<i class="fas fa-plus"></i>
</a>
</td>
</tr>
</tbody>
button in last column starts a modal. In modal I can add some value for a record:
<form th:action="@{/add-data}"
method="post"
class="form">
<input name="NEW-DATA">
<div class="modal-footer">
<button name="login-submit"
type="submit">
<i class="fas fa-plus"></i>
</button>
</div>
</form>
and this is my controller:
@PostMapping("/add-data")
public String addData(@RequestParam String URL) {
... do logic...
return "index";
}
I get correct input value in my addData() method, but I cannot find a way to pass an id from object that was clicked on a list in a first place.
I need this object id to be able to correctly store additional information.
I think of maybe doing separate page for adding this information for each record but that seems not right with easy and small eddits/additions.
Is there any way to be able to add edits on modals in Spring Boot? I was not able to find proper answer for that anywhere, so here I am.