Ace
Ace

Reputation: 869

Checkbox not returing value in Param

I am having an issue that when an I return from adding or editing an entity, the param.book_hardcoverFlag is not set properly (there is no entry for that param anymore) if the check box is unchecked.

...
<td class="field">
  <input type="checkbox" class="checkbox" 
  name="book_hardcoverFlag" id="book_hardcoverFlag" 
  value="Y" ${params.book_hardcoverFlag eq 'Y' ? 'checked' : ''}/>
</td>
...

When the form get populated, it is properly presented, but if you uncheck the box or if the box is never checked, then the params.book_hardcoverFlag is never set when it tries to save.

Upvotes: 0

Views: 222

Answers (1)

Gabriel J&#252;rgens
Gabriel J&#252;rgens

Reputation: 3153

I think you should put it this way

<td class="field">
  <input type="checkbox" class="checkbox" 
  name="book_hardcoverFlag" id="book_hardcoverFlag" 
  value="Y" checked="${params.book_hardcoverFlag eq 'Y' ? 'checked' : ''}" />
</td>

Notice that it will output checked="checked" inside the tag.

Hope that fixes your problem!

Upvotes: 1

Related Questions