CHtml::hiddenField support for array values

Hi all,

may be it will be useful to add support of array values to CHtml::hiddenField .

Example implementation:




public static function hiddenField($name,$value='',$htmlOptions=array())

{

	if (is_array($value)) {

    	$result = '';

    	foreach ($value as $key=>$val) {

        	$result .= self::inputField('hidden',"$name[$key]",$val,$htmlOptions);

    	}

    	return $result;

	}

	else {

    	return self::inputField('hidden',$name,$value,$htmlOptions);

	}

}



it seems strange to me they don’t support array of values (i need it!). thanks for sharing the code

CHtml implements wrapper most commonly used HTML entities.

Hidden fields are not used in arrays in most cases, moreover, writing a custom method for such small feature can always workout the way MadAnd explained.