<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>customr registration attribute Archives - gj</title>
	<atom:link href="https://blog.gaiterjones.com/tag/customr-registration-attribute/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.gaiterjones.com/tag/customr-registration-attribute/</link>
	<description>gaiterjones</description>
	<lastBuildDate>Fri, 18 Dec 2020 14:08:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.3</generator>
	<item>
		<title>Magento 2 Custom Customer Registration Checkbox and Text Attributes</title>
		<link>https://blog.gaiterjones.com/magento-2-custom-customer-registration-checkbox-and-text-attributes/</link>
					<comments>https://blog.gaiterjones.com/magento-2-custom-customer-registration-checkbox-and-text-attributes/#respond</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Fri, 18 Dec 2020 14:04:31 +0000</pubDate>
				<category><![CDATA[Magento2]]></category>
		<category><![CDATA[customr registration attribute]]></category>
		<guid isPermaLink="false">https://blog.gaiterjones.com/?p=2371</guid>

					<description><![CDATA[I spent many hours recently trying to figure out why a custom Magento 2 customer registration attribute was not working only to find that a relatively simple mistake was the...<a class="more-link" href="https://blog.gaiterjones.com/magento-2-custom-customer-registration-checkbox-and-text-attributes/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p>I spent many hours recently trying to figure out why a custom Magento 2 customer registration attribute was not working only to find that a relatively simple mistake was the culprit.</p>
<p>The attribute appeared to be created correctly in the <code>eav_attribute</code> database table, but the frontend value was not being saved to the database when the customer registered.</p>
<p>The attribute was a checkbox, which has a boolean true/false value. As I set the checkbox to be checked by default, my mistake was simply not to set a default value which meant that no value for the custom attribute was being passed via the registration form to the backend customer registration / creation process.</p>
<pre class="brush: php; title: ; notranslate">
    &lt;div class=&quot;field gj_custom_boolean_attribute&quot;&gt;
        &lt;label for=&quot;gj_custom_boolean_attribute&quot; class=&quot;label&quot;&gt;&lt;span&gt;&lt;?php /* @escapeNotVerified */
                echo __('Customer Custom Boolean Attribute') ?&gt;&lt;/span&gt;
        &lt;/label&gt;
        &lt;div class=&quot;control&quot;&gt;
            &lt;input type=&quot;checkbox&quot; checked name=&quot;gj_custom_boolean_attribute&quot; id=&quot;gj_custom_boolean_attribute&quot; title=&quot;&lt;?php /* @escapeNotVerified */
            echo __('Customer Custom Boolean Attribute') ?&gt;&quot; class=&quot;input-text&quot; autocomplete=&quot;off&quot; value=&quot;1&quot;&gt;
        &lt;/div&gt;
    &lt;/div&gt;
</pre>
<p>In case anyone else is trying to create a custom checkbox (boolean) attribute and experiencing the same mind numbingly annoying problem here is a module with a demonstration of two custom Magento 2 attributes &#8211; checkbox and text input that demonstrates the correct working code.</p>
<figure id="attachment_2374" aria-describedby="caption-attachment-2374" style="width: 600px" class="wp-caption aligncenter"><img fetchpriority="high" decoding="async" src="https://blog.gaiterjones.com/wp-content/uploads/2020/12/customerregistration_1.jpg" alt="" width="600" height="242" class="size-full wp-image-2374" srcset="https://blog.gaiterjones.com/wp-content/uploads/2020/12/customerregistration_1.jpg 600w, https://blog.gaiterjones.com/wp-content/uploads/2020/12/customerregistration_1-440x177.jpg 440w, https://blog.gaiterjones.com/wp-content/uploads/2020/12/customerregistration_1-550x222.jpg 550w" sizes="(max-width: 600px) 100vw, 600px" /><figcaption id="caption-attachment-2374" class="wp-caption-text">Magento 2 Custom Customer Registration Attributes</figcaption></figure>
<p><a href="https://github.com/gaiterjones/Magento2_Gaiterjones_CustomerRegistration" rel="noopener" target="_blank">https://github.com/gaiterjones/Magento2_Gaiterjones_CustomerRegistration</a></p>
<p>The module creates two attributes:</p>
<ul>
<li>gj_custom_boolean_attribute &#8211; a sample boolean checkbox attribute</li>
<li>gj_custom_text_attribute &#8211;  a sample text attribute</li>
</ul>
<p>The additional registration html is in the <code>additionalinfocustomer.phtml</code> template file. Note here that the checkbox requires a default value</p>
<p><code>value="1"</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/magento-2-custom-customer-registration-checkbox-and-text-attributes/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
