[Skip to main content](#vessel-content)

#   Conditional Fields in Form

##

- **[oharris](/forum/user/946-oharris "View oharris's Profile")**
- [![oharris's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/946-oharris "View oharris's Profile") Topic Author
- [ Offline](/forum/user/946-oharris)

Less More

- Posts: 53
- Thank you received: 0
-
-

12 years 5 months ago [\#158477](#158477) by [oharris](/forum/user/946-oharris "View oharris's Profile")  *[Conditional Fields in Form](/forum/27-checkout/868703-conditional-fields-in-form#158477 "-- url of the page with the problem -- :   vazprep.edu.jm/registration.html  -- HikaShop version -- : 2.2 -- Joomla version -- : 2.5  I am trying to have a conditional field in the checkout Form. But having some issues. I tried your forum and found this link:   www.hikashop.com/forum/4-how-to/42933-co...required-fields.html  We tried to replicate, but it did not work for us. Could you say what we may have done wrong?   This is the modified code for the multiple registrant ..for our site    loadFullCart(true); $this-&gt;rows =&amp; $cart-&gt;products; $multipleregistrant = false; foreach($this-&gt;rows as $row){ $productClass = hikashop&#95;get('class.product'); $product = $productClass-&gt;get($row-&gt;product&#95;id); if($product-&gt;multipleregistrant == &quot;TRUE&quot; ) $multipleregistrant = true; }  if(!$multipleregistrant ){ $doc =&amp; JFactory::getDocument(); $js=&quot;hikashop = Array();&quot;; $doc-&gt;addScriptDeclaration( &quot;&#92;n&quot; ); return; } ?&gt;  extraFields) &amp;&amp; $multipleregistrant == true){  ?&gt;     extraFields)){ JRequest::setVar('hikashop&#95;check&#95;order',1); $this-&gt;setLayout('custom&#95;fields'); $this-&gt;type = 'order'; echo $this-&gt;loadTemplate(); } ?&gt;     ")* was created by *[oharris](/forum/user/946-oharris "View oharris's Profile")*

-- url of the page with the problem -- : [ vazprep.edu.jm/registration.html](http://vazprep.edu.jm/registration.html)
-- HikaShop version -- : 2.2
-- Joomla version -- : 2.5

I am trying to have a conditional field in the checkout Form. But having some issues. I tried your forum and found this link: [ www.hikashop.com/forum/4-how-to/42933-co...required-fields.html](http://www.hikashop.com/forum/4-how-to/42933-conditional-required-fields.html)

We tried to replicate, but it did not work for us. Could you say what we may have done wrong?
&lt;

---

&gt;

This is the modified code for the multiple registrant ..for our site

&lt;

---

&gt;

&lt;?php
$cartClass = hikashop_get('class.cart');
$cart = $cartClass-&gt;loadFullCart(true);
$this-&gt;rows =&amp; $cart-&gt;products;
$multipleregistrant = false;
foreach($this-&gt;rows as $row){
$productClass = hikashop_get('class.product');
$product = $productClass-&gt;get($row-&gt;product_id);
if($product-&gt;multipleregistrant == "TRUE" ) $multipleregistrant = true;
}

if(!$multipleregistrant ){
$doc =&amp; JFactory::getDocument();
$js="hikashop = Array();";
$doc-&gt;addScriptDeclaration( "&lt;!--\n".$js."\n//--&gt;\n" );
return;
}
?&gt;

&lt;?php if(hikashop_level(2) &amp;&amp; !empty($this-&gt;extraFields) &amp;&amp; $multipleregistrant == true){

?&gt;
&lt;div id="hikashop_checkout_additional_info" class="hikashop_checkout_additional_info"&gt;
&lt;fieldset class="input"&gt;
&lt;legend&gt;&lt;?php echo JText::_('ADDITIONAL_INFORMATION');?&gt;&lt;/legend&gt;
&lt;table cellpadding="0" cellspacing="0" border="0" class="hikashop_contentpane"&gt;
&lt;?php
if(!empty($this-&gt;extraFields)){
JRequest::setVar('hikashop_check_order',1);
$this-&gt;setLayout('custom_fields');
$this-&gt;type = 'order';
echo $this-&gt;loadTemplate();
}
?&gt;
&lt;/table&gt;
&lt;/fieldset&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;&lt;/div&gt;
&lt;?php } ?&gt;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg2ODcwMy1jb25kaXRpb25hbC1maWVsZHMtaW4tZm9ybT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

12 years 5 months ago [\#158501](#158501) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Conditional Fields in Form](/forum/27-checkout/868703-conditional-fields-in-form#158501 "-- url of the page with the problem -- :   vazprep.edu.jm/registration.html  -- HikaShop version -- : 2.2 -- Joomla version -- : 2.5  I am trying to have a conditional field in the checkout Form. But having some issues. I tried your forum and found this link:   www.hikashop.com/forum/4-how-to/42933-co...required-fields.html  We tried to replicate, but it did not work for us. Could you say what we may have done wrong?   This is the modified code for the multiple registrant ..for our site    loadFullCart(true); $this-&gt;rows =&amp; $cart-&gt;products; $multipleregistrant = false; foreach($this-&gt;rows as $row){ $productClass = hikashop&#95;get('class.product'); $product = $productClass-&gt;get($row-&gt;product&#95;id); if($product-&gt;multipleregistrant == &quot;TRUE&quot; ) $multipleregistrant = true; }  if(!$multipleregistrant ){ $doc =&amp; JFactory::getDocument(); $js=&quot;hikashop = Array();&quot;; $doc-&gt;addScriptDeclaration( &quot;&#92;n&quot; ); return; } ?&gt;  extraFields) &amp;&amp; $multipleregistrant == true){  ?&gt;     extraFields)){ JRequest::setVar('hikashop&#95;check&#95;order',1); $this-&gt;setLayout('custom&#95;fields'); $this-&gt;type = 'order'; echo $this-&gt;loadTemplate(); } ?&gt;     ")*

Hi,

Conditional custom fields can now be done with the "display limited to" option of the custom fields. No need to change any code.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg2ODcwMy1jb25kaXRpb25hbC1maWVsZHMtaW4tZm9ybT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[oharris](/forum/user/946-oharris "View oharris's Profile")**
- [![oharris's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/946-oharris "View oharris's Profile") Topic Author
- [ Offline](/forum/user/946-oharris)

Less More

- Posts: 53
- Thank you received: 0
-
-

12 years 5 months ago [\#158684](#158684) by [oharris](/forum/user/946-oharris "View oharris's Profile")  Replied by *[oharris](/forum/user/946-oharris "View oharris's Profile")* on topic *[Conditional Fields in Form](/forum/27-checkout/868703-conditional-fields-in-form#158684 "-- url of the page with the problem -- :   vazprep.edu.jm/registration.html  -- HikaShop version -- : 2.2 -- Joomla version -- : 2.5  I am trying to have a conditional field in the checkout Form. But having some issues. I tried your forum and found this link:   www.hikashop.com/forum/4-how-to/42933-co...required-fields.html  We tried to replicate, but it did not work for us. Could you say what we may have done wrong?   This is the modified code for the multiple registrant ..for our site    loadFullCart(true); $this-&gt;rows =&amp; $cart-&gt;products; $multipleregistrant = false; foreach($this-&gt;rows as $row){ $productClass = hikashop&#95;get('class.product'); $product = $productClass-&gt;get($row-&gt;product&#95;id); if($product-&gt;multipleregistrant == &quot;TRUE&quot; ) $multipleregistrant = true; }  if(!$multipleregistrant ){ $doc =&amp; JFactory::getDocument(); $js=&quot;hikashop = Array();&quot;; $doc-&gt;addScriptDeclaration( &quot;&#92;n&quot; ); return; } ?&gt;  extraFields) &amp;&amp; $multipleregistrant == true){  ?&gt;     extraFields)){ JRequest::setVar('hikashop&#95;check&#95;order',1); $this-&gt;setLayout('custom&#95;fields'); $this-&gt;type = 'order'; echo $this-&gt;loadTemplate(); } ?&gt;     ")*

Thank you. We tried. But it works only if the selected value is yes (of radio-buttons), so the fields are exposed. We really want no fields to be available, but fields only displays when yes is selected. how can that be done?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg2ODcwMy1jb25kaXRpb25hbC1maWVsZHMtaW4tZm9ybT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

12 years 5 months ago [\#158696](#158696) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Conditional Fields in Form](/forum/27-checkout/868703-conditional-fields-in-form#158696 "-- url of the page with the problem -- :   vazprep.edu.jm/registration.html  -- HikaShop version -- : 2.2 -- Joomla version -- : 2.5  I am trying to have a conditional field in the checkout Form. But having some issues. I tried your forum and found this link:   www.hikashop.com/forum/4-how-to/42933-co...required-fields.html  We tried to replicate, but it did not work for us. Could you say what we may have done wrong?   This is the modified code for the multiple registrant ..for our site    loadFullCart(true); $this-&gt;rows =&amp; $cart-&gt;products; $multipleregistrant = false; foreach($this-&gt;rows as $row){ $productClass = hikashop&#95;get('class.product'); $product = $productClass-&gt;get($row-&gt;product&#95;id); if($product-&gt;multipleregistrant == &quot;TRUE&quot; ) $multipleregistrant = true; }  if(!$multipleregistrant ){ $doc =&amp; JFactory::getDocument(); $js=&quot;hikashop = Array();&quot;; $doc-&gt;addScriptDeclaration( &quot;&#92;n&quot; ); return; } ?&gt;  extraFields) &amp;&amp; $multipleregistrant == true){  ?&gt;     extraFields)){ JRequest::setVar('hikashop&#95;check&#95;order',1); $this-&gt;setLayout('custom&#95;fields'); $this-&gt;type = 'order'; echo $this-&gt;loadTemplate(); } ?&gt;     ")*

Hi,

As Nicolas said, you have to create the first custom field, the radio button one.
Then create the other custom field, add values, save it, set select a value for "option limited to", the value must be the previously created custom field (radio button), and select the desired value of this radio button.

Doing it like that, the second custom field values will be displayed only when "yes" is selected for the first one.
If you don't see the values in the display limited to option, thanks to update your version of HikaShop by downloading it from our website.

The following user(s) said Thank You: [oharris](/forum/user/946-oharris "View oharris's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg2ODcwMy1jb25kaXRpb25hbC1maWVsZHMtaW4tZm9ybT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[oharris](/forum/user/946-oharris "View oharris's Profile")**
- [![oharris's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/946-oharris "View oharris's Profile") Topic Author
- [ Offline](/forum/user/946-oharris)

Less More

- Posts: 53
- Thank you received: 0
-
-

12 years 5 months ago [\#159414](#159414) by [oharris](/forum/user/946-oharris "View oharris's Profile")  Replied by *[oharris](/forum/user/946-oharris "View oharris's Profile")* on topic *[Conditional Fields in Form](/forum/27-checkout/868703-conditional-fields-in-form#159414 "-- url of the page with the problem -- :   vazprep.edu.jm/registration.html  -- HikaShop version -- : 2.2 -- Joomla version -- : 2.5  I am trying to have a conditional field in the checkout Form. But having some issues. I tried your forum and found this link:   www.hikashop.com/forum/4-how-to/42933-co...required-fields.html  We tried to replicate, but it did not work for us. Could you say what we may have done wrong?   This is the modified code for the multiple registrant ..for our site    loadFullCart(true); $this-&gt;rows =&amp; $cart-&gt;products; $multipleregistrant = false; foreach($this-&gt;rows as $row){ $productClass = hikashop&#95;get('class.product'); $product = $productClass-&gt;get($row-&gt;product&#95;id); if($product-&gt;multipleregistrant == &quot;TRUE&quot; ) $multipleregistrant = true; }  if(!$multipleregistrant ){ $doc =&amp; JFactory::getDocument(); $js=&quot;hikashop = Array();&quot;; $doc-&gt;addScriptDeclaration( &quot;&#92;n&quot; ); return; } ?&gt;  extraFields) &amp;&amp; $multipleregistrant == true){  ?&gt;     extraFields)){ JRequest::setVar('hikashop&#95;check&#95;order',1); $this-&gt;setLayout('custom&#95;fields'); $this-&gt;type = 'order'; echo $this-&gt;loadTemplate(); } ?&gt;     ")*

Thank you. All good now. I installed your latest version (2.3.1)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg2ODcwMy1jb25kaXRpb25hbC1maWVsZHMtaW4tZm9ybT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.069 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
