• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Spring MVC Form Checkbox vs Checkboxes

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am facing strange problem with form:checkbox attribute in my Spring MVC form. I am trying to display and edit checkbox values and I don't understand why "form:checkboxes" is working and "form:checkbox" is not.

Here is my code:


The result page screenshot is attached. First checkbox is working, the second one in forEach is not checked and I do not why.


Am I doing anything wrong?
Unfortunately I have to use checkbox with forEach to add more elements.

I am using Spring version 5.1.9.RELEASE

Any advice is appreciated!
Sni-mek-obrazovky-2021-02-18-v-17.44.41.png
[Thumbnail for Sni-mek-obrazovky-2021-02-18-v-17.44.41.png]
 
Bartender
Posts: 2037
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not familiar with Spring MVC form.
But one experiment you can first try is to replace the forEach by multiple checkbox, like this example:
https://mkyong.com/spring-mvc/spring-mvc-checkbox-and-checkboxes-example/
 
Mick Common
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replay, I already tried "checkboxes" element and it is written in my post, this approach works! Unfortunately I need to use checkbox inside forEach to add more elements.
 
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic