<?if($prop_fields["PROPERTY_TYPE"]=="L"&&$prop_fields["LIST_TYPE"]!="C"):?>
<?MyShowListPropertyField('PROP['.$prop_fields["ID"].']', $prop_fields, $prop_fields["VALUE"], (($historyId <= 0) && (!$bVarsFromForm) && ($ID<=0)));?>
<?else:?>
<?_ShowPropertyField('PROP['.$prop_fields["ID"].']', $prop_fields, $prop_fields["VALUE"], (($historyId <= 0) && (!$bVarsFromForm) && ($ID<=0)), $bVarsFromForm, 50000, $tabControl->GetFormName());?>
<?endif;?>
<?function MyShowListPropertyField($name, $property_fields, $values, $bInitDef = false, $def_text = false)
{
if(!is_array($values)) $values = Array();
foreach($values as $key => $value)
{
if(is_array($value) && array_key_exists("VALUE", $value))
$values[$key] = $value["VALUE"];
}
$id = $property_fields["ID"];
$res = "";
$bNoValue = true;
$prop_enums = CIBlockProperty::GetPropertyEnum($id, array("SORT"=>"ASC", "VALUE"=>"ASC"));
while($ar_enum = $prop_enums->Fetch())
{
if($bInitDef)
$sel = ($ar_enum["DEF"]=="Y");
else
$sel = in_array($ar_enum["ID"], $values);
if($sel)
$bNoValue = false;
$res .= '<option value="'.htmlspecialchars($ar_enum["ID"]).'"'.($sel?" selected":"").'>'.htmlspecialcharsex($ar_enum["VALUE"]).'</option>';
}
if($property_fields["MULTIPLE"]=="Y" && IntVal($property_fields["ROW_COUNT"])<2)
$property_fields["ROW_COUNT"] = 5;
if($property_fields["MULTIPLE"]=="Y")
$property_fields["ROW_COUNT"]++;
$res = '<select name="'.$name.'[]" size="'.$property_fields["ROW_COUNT"].'" '.($property_fields["MULTIPLE"]=="Y"?"multiple":"").'>'.
'<option value=""'.($bNoValue?' selected':'').'>'.htmlspecialcharsex(($def_text ? $def_text : GetMessage("IBLOCK_ELEMENT_PROP_NA") )).'</option>'.
$res.
'</select>';
echo $res;
}?> |