Is a list custom field bug - cannot change the value if once selected

Started by Gruz, March 24, 2012, 22:18:35 PM

Previous topic - Next topic

Gruz

J.2.5.3
VM SVN, 2.0.3.G

I add a custom field.


Next I add it to a product and can select an item



I press save and cannot change the item anymore:



Solution

administrator/components/com_virtuemart/models/customfields.php

Change

$values = explode(';',$field->custom_value);

foreach ($values as $key => $val){
$options[] = array( 'value' => $val ,'text' =>$val);
}

return JHTML::_('select.genericlist', $options,'field['.$row.'][custom_value]').'</td><td>'.$priceInput;



to


$values = explode(';',$field->value);

$selected = null;
foreach ($values as $key => $val){
if ($field->custom_value == $val) {
$selected = $val;
}
if (empty ($val)) {
$options[] = array( 'value' => $val ,'text' =>JText::_('COM_VIRTUEMART_NONE'));
continue;
}
$options[] = array( 'value' => $val ,'text' =>$val);
}

return JHTML::_('select.genericlist', $options,'field['.$row.'][custom_value]',null,'value','text',$selected).'</td><td>'.$priceInput;



Result:



Diff:


Index: administrator/components/com_virtuemart/models/customfields.php
===================================================================
--- administrator/components/com_virtuemart/models/customfields.php (revision 5705)
+++ administrator/components/com_virtuemart/models/customfields.php (working copy)
@@ -332,13 +332,21 @@

if ($field->is_list) {
$options = array();
- $values = explode(';',$field->custom_value);
+ $values = explode(';',$field->value);

+ $selected = null;
foreach ($values as $key => $val){
+ if ($field->custom_value == $val) {
+ $selected = $val;
+ }
+ if (empty ($val)) {
+ $options[] = array( 'value' => $val ,'text' =>JText::_('COM_VIRTUEMART_NONE'));
+ continue;
+ }
$options[] = array( 'value' => $val ,'text' =>$val);
}

- return JHTML::_('select.genericlist', $options,'field['.$row.'][custom_value]').'</td><td>'.$priceInput;
+ return JHTML::_('select.genericlist', $options,'field['.$row.'][custom_value]',null,'value','text',$selected).'</td><td>'.$priceInput;
} else {

switch ($field->field_type) {


Your installable language for VM2: http://gruz.org.ua/virtuemart-language-files.html