0

I am trying to leverage the Lexicon library toggles within a Liferay Spring MVC Portlet. I am using the Spring command for their form tag. Which get my POJO class boolean property. I set this to true and "bind" the value to the input value tag but switch does not renders as "on". JSP:

<label> 
            <input name="POJO boolean property" id="POJO boolean property" value="${POJO boolean property}" class="toggle-switch" type="checkbox"> 
             <span aria-hidden="true" class="toggle-switch-bar"> 
                <span class="toggle-switch-handle"> 
                  <span aria-hidden="true" class="icon-ok toggle-switch-icon toggle-switch-icon-on">
                  </span>
                <span aria-hidden="true" class="icon-remove toggle-switch-icon toggle-switch-icon-off">
                </span>
             </span></span> 
        </input>
    </label>
esanfio
  • 33
  • 1
  • 8

1 Answers1

0

The value attribute for checkbox input does not determinate the checked status.

You have to bind che checked attribute.

Example: <input name="POJO boolean property" id="POJO boolean property" value="1" class="toggle-switch" type="checkbox" ${POJO-boolean-property ? 'checked' : ''}>

Look the input checkbox guide here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox

Daniele Baggio
  • 2,157
  • 1
  • 14
  • 21