[keycloak-user] Checkbox in User Attributes

Chris Hairfield chairfield at gmail.com
Fri May 20 11:21:22 EDT 2016


Hello,

We're running into an issue unchecking a checkbox in our account theme and
came across the following post with no answer. As Libor asks the question
elegantly, I'll copy his text verbatim and hope someone now has an answer.

Hi,
I’d like to use user attributes to store information like “Subscribe
to newsletter” which is obviously checkbox.

How should I implement it in my account.ftl?

I have in account.flt:
<div class="form-group">
   <div class="checkbox">
      <label for="user.attributes.newsletter" class="control-label">
         <input type="checkbox" class="form-control"
id="user.attributes.newsletter" name="user.attributes.newsletter" <#if
account.attributes.newsletter??>checked</#if>/>
         ${msg("newsletter")}
      </label>
   </div>
</div>


When I tick it and submit form everything is OK but when untick it and
submit then checkbox is still checked.
I guess it’s because checkbox state is included in HTTP Form Data only
when it’s checked.

How to handle this in KC UI ?

I remember that other frameworks used some hidden fields to post the
information either if checkbox was ticked or not. But I’m not sure how
KC GUI framework handle this use case.

Thanks,

Libor Krzyžanekjboss.org <http://jboss.org/> Development Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20160520/73b33d79/attachment-0001.html 


More information about the keycloak-user mailing list