[keycloak-user] User attributes - checkbox

Libor Krzyžanek lkrzyzan at redhat.com
Mon Apr 20 05:00:11 EDT 2015


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žanek
jboss.org <http://jboss.org/> Development Team

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20150420/4959201c/attachment-0001.html 


More information about the keycloak-user mailing list