<p>When the checkbox get submitted, it get's transferred with whatever value is set with the value attribute.</p>

<p>Thus, your need to set the value to 1. Your code should be more like this:</p>

<pre><code>&lt;div class="checkbox"&gt;
  &lt;label&gt;
    &lt;input type="checkbox" id="memberShowEmailLink" name="fields[memberShowEmailLink]" value="1" {% if account is defined and account.memberShowEmailLink %} checked="checked"{% endif %}&gt;
    Show a link to contact me via email in the member directory?
  &lt;/label&gt;
&lt;/div&gt;
</code></pre>

CC BY-SA 3.0
2015-01-08T16:52:36.910Z
I'd like these checkboxes to be off by default, which is why I set the `value="0"` in the `else` bit of my conditional. But when I check them on in the frontend, the value is not getting transferred.
Adam Snetman
CC BY-SA 3.0
2015-01-08T16:53:20.393Z
They are "off" by default. The checked attribute controls if they are "on". If they aren't checked, the field isn't transferred to the server.
Fred Carlsen
CC BY-SA 3.0
2015-01-08T16:58:13.133Z
Got it! Tried the code you revised and it worked great. Thanks for clarifying!
Adam Snetman
CC BY-SA 3.0
2015-01-08T16:47:23.887Z
2015-01-08T17:24:31.447Z
2015-01-08T17:24:31.447Z
Fred Carlsen
<p>I've got a frontend user registration form working that's populating a whole set of custom fields I've set up on my user profiles in Craft.</p>

<p>But I've got a set of lightswitch fields on my user profiles that I'm trying to set via checkboxes in the registration form but the values are not transferring over when submitting the form.</p>

<p>Here's an example of my checkbox code in the frontend form (the corresponding lightswitch field handle is <code>memberShowEmailLink</code>):</p>

<pre><code>&lt;div class="checkbox"&gt;
  &lt;label&gt;
    &lt;input type="checkbox" id="memberShowEmailLink" name="fields[memberShowEmailLink]" {% if account is defined %}value="{{ account.memberShowEmailLink }}" checked="checked"{% else %}value="0"{% endif %}&gt;
    Show a link to contact me via email in the member directory?
  &lt;/label&gt;
&lt;/div&gt;
</code></pre>

<p>Is there a way to change it to make this work?</p>

<registration><custom-field><frontend>
How can I translate checkboxes on a frontend user registration form to lightswitch custom fields?
# How can I translate checkboxes on a frontend user registration form to lightswitch custom fields?

(Asked by: username_0 on 2015-01-08)

I've got a frontend user registration form working that's populating a whole set of custom fields I've set up on my user profiles in Craft.
But I've got a set of lightswitch fields on my user profiles that I'm trying to set via checkboxes in the registration form but the values are not transferring over when submitting the form.
Here's an example of my checkbox code in the frontend form (the corresponding lightswitch field handle is memberShowEmailLink):

  
    
    Show a link to contact me via email in the member directory?
  


Is there a way to change it to make this work?

**Tags:** registration, custom-field, frontend

---

## 1 answers

### Answer by username_1 on 2015-01-08. Score: 1 | Accepted answer

When the checkbox get submitted, it get's transferred with whatever value is set with the value attribute.
Thus, your need to set the value to 1. Your code should be more like this:

  
    
    Show a link to contact me via email in the member directory?

> **Comments:**
> **username_0**: I'd like these checkboxes to be off by default, which is why I set the `value="0"` in the `else` bit of my conditional. But when I check them on in the frontend, the value is not getting transferred.  
> **username_1**: They are "off" by default. The checked attribute controls if they are "on". If they aren't checked, the field isn't transferred to the server.  
> **username_0**: Got it! Tried the code you revised and it worked great. Thanks for clarifying!  

---

