VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: dimadav on July 08, 2012, 19:05:58 PM

Title: [SOLVED] incorrectly formed id input radio in TextArea
Post by: dimadav on July 08, 2012, 19:05:58 PM
should be different ID input radio
I changed:
administrator\components\com_virtuemart\models\customfields.php

                        $idav = 1;
                        foreach ($group->options as $productCustom) {
                           //vmdebug('getProductCustomsFieldCart',$productCustom);
                           if ((float)$productCustom->custom_price) {
                              $price = $currency->priceDisplay ($calculator->calculateCustomPriceWithTax ($productCustom->custom_price));
                           }
                           else {
                              $price = ($productCustom->custom_price === '') ? '' : $free;
                           }
                           $productCustom->field_type = $group->field_type;
                           $productCustom->is_cart = 1;
                        //   $group->display .= '<input id="' . $productCustom->virtuemart_custom_id . '" ' . $checked . ' type="radio" value="' .
                        //      $productCustom->virtuemart_custom_id . '" name="customPrice[' . $row . '][' . $productCustom->virtuemart_customfield_id . ']" /><label
                        //      for="' . $productCustom->virtuemart_custom_id . '">' . $this->displayProductCustomfieldFE ($productCustom, $row) . ' ' . $price . '</label>';
                  //MarkerVarMods
                           $group->display .= '<input id="' . $productCustom->virtuemart_custom_id . '_' . $idav . '" ' . $checked . ' type="radio" value="' .
                              $productCustom->virtuemart_customfield_id . '" name="customPrice[' . $row . '][' . $productCustom->virtuemart_custom_id . ']" /><label
                              for="' . $productCustom->virtuemart_custom_id . '_' . $idav . '">' . $this->displayProductCustomfieldFE ($productCustom, $row) . ' ' . $price . '</label>';

                           $checked = '';
                        $idav++;   
                        }

is that right? thank you
Title: Re: incorrectly formed id input radio in TextArea
Post by: doriandsp on July 09, 2012, 18:14:16 PM
I have the same problem,  always id="5"...  :-[ :-[   using Virtuemart 2.0.8c and joomla 2.5.6


<input id="5" type="radio" name="customPrice[0][5]" value="8" checked="checked">

<label for="5">Lorem</label>

<input id="5" type="radio" name="customPrice[0][5]" value="9">

<label for="5">Ipsum</label>





Title: Re: incorrectly formed id input radio in TextArea
Post by: dimadav on July 09, 2012, 22:13:13 PM
I wrote the above code, the solution to this problem, it would be good for developers to have corrected itself, this is a bug
Title: Re: incorrectly formed id input radio in TextArea
Post by: doriandsp on July 10, 2012, 12:59:00 PM
Your code works like a charm, thanks!
Title: Re: [SOLVED] incorrectly formed id input radio in TextArea
Post by: Jumbo! on August 23, 2012, 17:28:04 PM
The bug still remains in VM 2.0.10.
Title: Re: [SOLVED] incorrectly formed id input radio in TextArea
Post by: Jumbo! on November 10, 2012, 18:05:11 PM
Same bug also remain in VM 2.0.12. It is a very simple fix but do not know why it is still not done in several past updates.
Title: Re: [SOLVED] incorrectly formed id input radio in TextArea
Post by: evan.ingram on January 11, 2013, 22:47:45 PM
hi there

ive tried inserting the suggested code but it doesnt seem to make any difference. im not 100% sure im inserting it in the right place. can someone tell me on what line i need to enter this code and what code to replace it with?

or upload a fixed file.

thanks
Title: Re: [SOLVED] incorrectly formed id input radio in TextArea
Post by: Jumbo! on January 14, 2013, 20:50:13 PM
Then you are not making the corrections properly. I am attaching the corrected copy of administrator\components\com_virtuemart\models\customfields.php

Unzip the attached package and replace the file in your site by this corrected one.



[attachment cleanup by admin]
Title: Re: [SOLVED] incorrectly formed id input radio in TextArea
Post by: evan.ingram on January 14, 2013, 22:24:05 PM
excellent many thanks. that worked. i didnt know what the bold sections in the original post meant.
Title: Re: [SOLVED] incorrectly formed id input radio in TextArea
Post by: Jumbo! on November 11, 2013, 07:14:10 AM
The problem remains in VirtueMart 2.0.24. It is still generating wrong HTML for string type custom fields. Here is the exact fix.


Open administrator\components\com_virtuemart\models\customfields.php

Find the following codes between lines 952 to 966:
foreach ($group->options as $productCustom) {
//vmdebug('getProductCustomsFieldCart',$productCustom);
$price = self::_getCustomPrice($productCustom->custom_price, $currency, $calculator);
$productCustom->field_type = $group->field_type;
$productCustom->is_cart = 1;
// $group->display .= '<input id="' . $productCustom->virtuemart_custom_id . '" ' . $checked . ' type="radio" value="' .
// $productCustom->virtuemart_custom_id . '" name="customPrice[' . $row . '][' . $productCustom->virtuemart_customfield_id . ']" /><label
// for="' . $productCustom->virtuemart_custom_id . '">' . $this->displayProductCustomfieldFE ($productCustom, $row) . ' ' . $price . '</label>';
//MarkerVarMods
$group->display .= '<input id="' . $productCustom->virtuemart_custom_id .$row. '" ' . $checked . ' type="radio" value="' .
$productCustom->virtuemart_customfield_id . '" name="customPrice[' . $row . '][' . $productCustom->virtuemart_custom_id . ']" /><label
for="' . $productCustom->virtuemart_custom_id .$row. '" class="other-customfield">' . $this->displayProductCustomfieldFE ($product, $productCustom, $row) . ' ' . $price . '</label>';

$checked = '';
}

Replace above by:
$i = 1;
foreach ($group->options as $productCustom) {
$price = self::_getCustomPrice($productCustom->custom_price, $currency, $calculator);
$productCustom->field_type = $group->field_type;
$productCustom->is_cart = 1;
$group->display .= '<input id="' . $productCustom->virtuemart_custom_id .$row. '-'.$i.'" ' . $checked . ' type="radio" value="' .
$productCustom->virtuemart_customfield_id . '" name="customPrice[' . $row . '][' . $productCustom->virtuemart_custom_id . ']" /><label
for="' . $productCustom->virtuemart_custom_id .$row. '-'.$i.'" class="other-customfield">' . $this->displayProductCustomfieldFE ($product, $productCustom, $row) . ' ' . $price . '</label>';

$checked = '';
$i++;
}


Hope this will fixed at least in the next update.