本文整理汇总了PHP中CActiveForm::radioButtonList方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveForm::radioButtonList方法的具体用法?PHP CActiveForm::radioButtonList怎么用?PHP CActiveForm::radioButtonList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveForm
的用法示例。
在下文中一共展示了CActiveForm::radioButtonList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: juiFlag
/**
* Encapsulates {@link CJuiButton} and {@link CHtml::radioButtonList} for an easy way to create input for flag fields.
* There are two uses for this method: static and active fields.
* Static fields make use of CHtml methods to create the radio buttons, and you'll only need the three first arguments.
* For use with {@link CActiveForm} you can skip the $value argument and supply $form and $model too, or use
* {@link activeJuiFlag}, that's a shorthand method to simplify this use.
*
* @param string $name the field name
* @param array $options a list of options, where the keys are the field values and
* the values are: a string with the label or an array where the first element
* is the label and the second is the icon class. For adding icons, you need to
* include CSS rules that add an image as background to that class, like:
* <code>.ui-icon-custom-yes { background-image: url(/images/icons/tick.png); }</code>
* @param mixed $value [optional] The current value for the field.
* @param CActiveForm [optional] $form the form widget being used
* @param CModel [optional] $model the model
*/
public function juiFlag($name, array $options, $value = null, CActiveForm $form = null, CModel $model = null)
{
$radio_options = $icons = array();
$button_number = 0;
foreach ($options as $value => $data) {
$radio_options[$value] = ($is_array = is_array($data)) ? $data[0] : $data;
if ($is_array && isset($data[1])) {
$icons[$button_number] = $data[1];
}
++$button_number;
}
$this->owner->beginWidget('zii.widgets.jui.CJuiButton', array('buttonType' => 'buttonset', 'name' => $name));
if ($form) {
echo $form->radioButtonList($model, $name, $radio_options, array('separator' => ''));
$radio_id_prefix = get_class($model) . '_' . $name;
} else {
echo CHtml::radioButtonList($name, $value, $radio_options, array('separator' => ''));
$radio_id_prefix = $name;
}
$this->owner->endWidget();
$js = function () use($icons, $radio_id_prefix) {
$js = '';
foreach ($icons as $i => $icon) {
$js .= "\$('#{$radio_id_prefix}_{$i}').button('option', 'icons', {primary: '{$icon}'})\n";
}
return $js;
};
Yii::app()->clientScript->registerScript("{$radio_id_prefix}_juiFlagIcons", $js());
}
示例2: explodeRadioButtonList
/**
* Explodes radioButtonList into array
* enabling to render buttons separately ($radio[0], $radio[1]...)
* @param CActiveForm $form the form widgets
* @param CModel $model the data model
* @param string $attribute the attribute
* @param array $data value-label pairs used to generate the radio button list.
* @return array of radio buttons
*/
public static function explodeRadioButtonList($form, $model, $attribute, $data)
{
return explode('|', $form->radioButtonList($model, $attribute, $data, array('template' => '{input}{label}', 'separator' => '|')));
}
示例3: radioButtonList
/**
* @inheritDoc
*/
public function radioButtonList($model, $attribute, $data, $htmlOptions = array())
{
if (!$this->qualifyNames && !isset($htmlOptions['name'])) {
$htmlOptions['name'] = $attribute;
}
if (!isset($htmlOptions['itemprop'])) {
$htmlOptions['itemprop'] = $this->getItemPropName($attribute);
}
return parent::radioButtonList($model, $attribute, $data, $htmlOptions);
}
示例4: radioButtonList
/**
* Renders a radio button list for a model attribute.
* @param CModel $parentModel the parent data model
* @param string $attributedPath the attribute or path to related model attribute
* @param array $data value-label pairs used to generate the radio button list.
* @param array $htmlOptions additional HTML options.
* @return string the generated radio button list
*/
public function radioButtonList($parentModel, $attributedPath, $data, $htmlOptions = array())
{
list($model, $attribute, $htmlOptions) = self::resolveArgs($parentModel, $attributedPath, $htmlOptions);
return parent::radioButtonList($model, $attribute, $data, $htmlOptions);
}