public static function activeDropDownList($model, $attribute, $data, $htmlOptions = array()) {
self::resolveNameID($model, $attribute, $htmlOptions);
$selection = self::resolveValue($model, $attribute);
$options = "\n" . self::listOptions($selection, $data, $htmlOptions);
self::clientChange('change', $htmlOptions);
if ($model->hasErrors($attribute))
self::addErrorCss($htmlOptions);
$hidden = '';
if (!empty($htmlOptions['multiple'])) {
if (substr($htmlOptions['name'], -2) !== '[]')
$htmlOptions['name'].='[]';
if (isset($htmlOptions['unselectValue'])) {
$hiddenOptions = isset($htmlOptions['id']) ? array('id' => self::ID_PREFIX . $htmlOptions['id']) : array('id' => false);
$hidden = self::hiddenField(substr($htmlOptions['name'], 0, -2), $htmlOptions['unselectValue'], $hiddenOptions);
unset($htmlOptions['unselectValue']);
}
}
return $hidden . self::tag('select', $htmlOptions, $options);
}
/**
*
* @param type $selection
* @param type $listData
* @param type $htmlOptions
* @return string
*/
public static function listOptions($selection, $listData, &$htmlOptions) {
$raw=isset($htmlOptions['encode']) && !$htmlOptions['encode'];
$content = '';
if (isset($htmlOptions['prompt'])) {
$content.='<option value="">' . strtr($htmlOptions['prompt'], array('<' => '&lt;', '>' => '&gt;')) . "</option>\n";
unset($htmlOptions['prompt']);
}
if (isset($htmlOptions['empty'])) {
if (!is_array($htmlOptions['empty']))
$htmlOptions['empty'] = array('' => $htmlOptions['empty']);
foreach ($htmlOptions['empty'] as $value => $label)
$content.='<option value="' . self::encode($value) . '">' . strtr($label, array('<' => '&lt;', '>' => '&gt;')) . "</option>\n";
unset($htmlOptions['empty']);
}
if (isset($htmlOptions['options'])) {
$options = $htmlOptions['options'];
unset($htmlOptions['options']);
}
else
$options = array();
$key = isset($htmlOptions['key']) ? $htmlOptions['key'] : 'primaryKey';
if (is_array($selection)) {
foreach ($selection as $i => $item) {
if (is_object($item))
$selection[$i] = $item->$key;
}
}
elseif (is_object($selection))
$selection = $selection->$key;
foreach ($listData as $key => $value) {
if (is_array($value)) {
$content.='<optgroup label="' . ($raw ? $key : self::encode($key)) . "\">\n";
$dummy = array('options' => $options);
if (isset($htmlOptions['encode']))
$dummy['encode'] = $htmlOptions['encode'];
$content.=self::listOptions($selection, $value, $dummy);
$content.='</optgroup>' . "\n";
}
else {
$attributes = array('value' => (string) $key, 'encode' => !$raw);
if (!is_array($selection) && !strcmp($key, $selection) || is_array($selection) && in_array($key, $selection))
$attributes['selected'] = 'selected';
if (isset($options[$key]))
$attributes = array_merge($attributes, $options[$key]);
$content.=self::tag('option', $attributes, $raw ? (string) $value : self::encode((string) $value)) . "\n";
}
}
unset($htmlOptions['key']);
return $content;
}
The line in listoption function having a problem
$raw=isset($htmlOptions['encode']) && !$htmlOptions['encode'];
My query was returning good currency symbol in CHtmllistdata
I made this line to
$raw=isset($htmlOptions['encode']);
Now its working
and i provide from my form is
<?php echo zHtml::activeDropDownList($model, ‘currency_id’, (BspCurrency::model()->getCurrencies()), array(‘class’ => ‘select2’, ‘encode’ => true)); ?>
Every thing is working now
I think its a yii bug