- Posts: 53
- Thank you received: 0
Conditional Fields in Form
12 years 5 months ago #158477
by oharris
Conditional Fields in Form was created by oharris
-- 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 } ?>
-- 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.
12 years 5 months ago #158501
by nicolas
Replied by nicolas on topic Conditional Fields in Form
Hi,
Conditional custom fields can now be done with the "display limited to" option of the custom fields. No need to change any code.
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.
12 years 5 months ago #158684
by oharris
Replied by oharris on topic Conditional Fields in Form
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.
12 years 5 months ago #158696
by Xavier
Replied by Xavier on topic Conditional Fields in Form
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.
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.
12 years 5 months ago #159414
by oharris
Replied by oharris on topic Conditional Fields in Form
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.083 seconds