jeudi 14 janvier 2021

Java Spring Boot checkbox toggle binding true/false

i try to bind data from database. I have in database a product entity and I will bind the enable data with the form on the front. The binding is working for read the data from databse, I mean if the product enable fieldd in the database is 0, then it shows "Disabled", and when the value is 1, then show "Enabled". But if I change the value in the front to "Disabled" or "Enabled" and then save the product, the enable field don't change in the database... And I don't have any idea why... Can someone help me please?

The binding:

<input type="checkbox" checked data-toggle="toggle" data-style="enabledStyleCss" 
                       name="isEnabled"  
                       data-on="Enabled" 
                       data-off="Disabled" 
                       data-onstyle="success" 
                       data-offstyle="danger"
                       th:value="${product.isEnabled}"
                       th:field="${product.isEnabled}"
                > 



Aucun commentaire:

Enregistrer un commentaire