Conditional Fields in Form

  • Posts: 53
  • Thank you received: 0
11 years 5 days ago #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

<
>



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

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


<?php if(hikashop_level(2) && !empty($this->extraFields) && $multipleregistrant == true){

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

Please Log in or Create an account to join the conversation.

  • Posts: 83933
  • Thank you received: 13588
  • MODERATOR
11 years 4 days ago #158501

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 or Create an account to join the conversation.

  • Posts: 53
  • Thank you received: 0
11 years 3 days ago #158684

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 or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 3 days ago #158696

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

Please Log in or Create an account to join the conversation.

  • Posts: 53
  • Thank you received: 0
10 years 11 months ago #159414

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

Please Log in or Create an account to join the conversation.

Time to create page: 0.071 seconds
Powered by Kunena Forum