SoCal
(Sasha81 Ca)
November 12, 2014, 8:29am
1
I get Array to string conversion when I use CHtml::listData with $groupField for CHtml::activeRadioButtonList.
$listData = CHtml::listData($data->markets, 'id', 'Market', 'Region_id');
echo CHtml::activeRadioButtonList($data->markets[0], 'id', $listData);
Why doesn’t it work with $groupField?
SoCal:
I get Array to string conversion when I use CHtml::listData with $groupField for CHtml::activeRadioButtonList.
$listData = CHtml::listData($data->markets, 'id', 'Market', 'Region_id');
echo CHtml::activeRadioButtonList($data->markets[0], 'id', $listData);
Why doesn’t it work with $groupField?
the reason is you don’t have Primary Key in your tables.
SoCal:
I get Array to string conversion when I use CHtml::listData with $groupField for CHtml::activeRadioButtonList.
$listData = CHtml::listData($data->markets, 'id', 'Market', 'Region_id');
echo CHtml::activeRadioButtonList($data->markets[0], 'id', $listData);
Why doesn’t it work with $groupField?
Hi,
It clearly show error… you are trying to pass string in case of array…please check the argument in original method. i think your listdata is not an array …its a guess. check and revert
public static string activeRadioButtonList(CModel $model, string $attribute, array $data, array $htmlOptions=array ( ))
SoCal
(Sasha81 Ca)
November 12, 2014, 5:08pm
4
I broke it further down.
public static function tag($tag,$htmlOptions=array(),$content=false,$closeTag=true)
157 {
158 $html='<' . $tag . self::renderAttributes($htmlOptions);
159 if($content===false)
160 return $closeTag && self::$closeSingleTags ? $html.' />' : $html.'>';
161 else
162 return $closeTag ? $html.'>'.$content.'</'.$tag.'>' : $html.'>'.$content;
163 }
it crashes because $content is an array in 162.
The content of $listData with a $groupField parameter turns into
array(2 => array(3 => 'MTN', 4 => 'PNW', 5 => 'NCA'))
It seems like the method in CHtml::activeRadioButtonList() doesn’t process properly the $listData when it’s grouped. Is this a bug in Yii 1.1.15? Is this working for any of you guys and which version do you have?