本文整理汇总了PHP中CHtml::radioButtonList方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::radioButtonList方法的具体用法?PHP CHtml::radioButtonList怎么用?PHP CHtml::radioButtonList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::radioButtonList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionGetVariations
public function actionGetVariations()
{
if (Yii::app()->request->isAjaxRequest && isset($_POST['product'])) {
$product = Products::model()->findByPk($_POST['product']);
echo CHtml::hiddenField('product_id', $product->product_id);
if ($variations = $product->getVariations()) {
foreach ($variations as $variation) {
$field = "Variations[{$variation[0]->specification_id}][]";
echo '<div class="shop-variation-element">';
echo '<strong>' . CHtml::label($variation[0]->specification->title . '</strong>', $field, array('class' => 'lbl-header'));
if ($variation[0]->specification->required) {
echo ' <span class="required">*</span>';
}
echo '<br />';
if ($variation[0]->specification->input_type == 'textfield') {
echo CHtml::textField($field);
} else {
if ($variation[0]->specification->input_type == 'select') {
// If the specification is required, preselect the first field.
// Otherwise let the customer choose which one to pick
// $product->variationCount > 1 ? true : false means, that the
// widget should display the _absolute_ price if only 1 variation
// is available, otherwise the relative (+ X $)
echo CHtml::radioButtonList($field, $variation[0]->specification->required ? $variation[0]->id : null, ProductVariation::listData($variation, $product->variationCount > 1 ? true : false), array('template' => '{input} {label}', 'separator' => '<div class="clear"></div>'));
}
}
echo '</div>';
}
}
} else {
throw new CHttpException(404);
}
}
示例2: 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());
}
示例3: renderBoolean
public function renderBoolean($name, array $metaData, $form = null)
{
$out = '';
$id = $name;
$value = isset($metaData['current']) ? $metaData['current'] : '';
if (isset($metaData['label'])) {
$out .= CHtml::label($metaData['label'], $id);
}
$out .= CHtml::radioButtonList($id, $value, array(0 => 'False', 1 => 'True'), array('id' => $id, 'form' => $form, 'container' => 'div', 'separator' => ''));
return $out;
}
示例4: listing
public function listing($model, $listModel, $relational, $type = 'checkbox')
{
self::startWidget(Ucfirst($listModel));
echo " <div style='max-height:300px;overflow:auto;border:1px solid #ddd;padding:10px;'>";
$cat = CHtml::listData($listModel::model()->findAll(array("order" => "name ASC")), 'term_id', 'name');
$selected_keys = array_keys(CHtml::listData($model->{$relational}, 'term_id', 'term_id'));
if ($type == 'checkbox') {
$selected_keys = isset($_POST[$relational]) ? $_POST[$relational] : $selected_keys;
echo CHtml::checkBoxList($relational, $selected_keys, $cat, array('separator' => '', 'template' => '<label class="' . $type . '"> {input}{label} </label>'));
} else {
$radioSelect = isset($_POST[$relational]) ? $_POST[$relational] : '';
foreach ($selected_keys as $key) {
$radioSelect = $key;
}
echo CHtml::radioButtonList($relational, $radioSelect, $cat, array('separator' => '', 'template' => '<label class="' . $type . '"> {input}{label} </label>'));
}
echo " </div>";
self::endWidget();
}
示例5: radioButtonSwitch
/**
* Generates a switch which only allows single selection.
* @param string $name name of the switch. You can use this name to retrieve
* the selected value(s) once the form is submitted.
* @param string $select selection of the radio buttons.
* @param array $data value-label pairs used to generate the radio button list.
* Note, the values will be automatically HTML-encoded, while the labels will not.
* @param array $htmlOptions addtional HTML options. The options will be applied to
* each radio button input. The following special options are recognized:
* <ul>
* <li>template: string, specifies how each radio button is rendered. Defaults
* to "{input} {label}", where "{input}" will be replaced by the generated
* radio button input tag while "{label}" will be replaced by the corresponding radio button label.</li>
* <li>separator: string, specifies the string that separates the generated radio buttons. Defaults to new line (<br/>).</li>
* <li>labelOptions: array, specifies the additional HTML attributes to be rendered
* for every label tag in the list.</li>
* <li>container: string, specifies the radio buttons enclosing tag. Defaults to 'span'.
* If the value is an empty string, no enclosing tag will be generated</li>
* </ul>
* @return string the generated radio button list
*/
public static function radioButtonSwitch($name, $select, $data, $htmlOptions = array())
{
$container = "div";
$template = isset($htmlOptions['template']) ? $htmlOptions['template'] : '{input} {label}';
$separator = isset($htmlOptions['separator']) ? $htmlOptions['separator'] : "";
unset($htmlOptions['template'], $htmlOptions['separator'], $htmlOptions['container']);
$labelOptions = isset($htmlOptions['labelOptions']) ? $htmlOptions['labelOptions'] : array();
unset($htmlOptions['labelOptions']);
$items = array();
$baseID = self::getIdByName($name);
$id = 0;
foreach ($data as $value => $label) {
$checked = !strcmp($value, $select);
$htmlOptions['value'] = $value;
$htmlOptions['id'] = $baseID . '_' . $id++;
$option = self::radioButton($name, $checked, $htmlOptions);
$label = self::label($label, $htmlOptions['id'], $labelOptions);
$items[] = strtr($template, array('{input}' => $option, '{label}' => $label));
}
return self::tag($container, array('id' => $baseID, 'class' => 'switch'), implode($separator, $items));
return CHtml::radioButtonList($name, $select, $data, $htmlOptions);
}
示例6: array
?>
</h3>
<div class="editinstructions">
<?php
echo Yii::t('admin', 'Choose the header image you wish to use with your theme. This image is used by both the site template as well as emailed receipts sent to customers.');
?>
</div>
<div class="clearfix spaceafter"></div>
<?php
echo CHtml::beginForm('header', 'post', array('enctype' => 'multipart/form-data'));
?>
<?php
echo CHtml::radioButtonList('headerimage', _xls_get_conf('HEADER_IMAGE'), $arrHeaderImages);
?>
<div class="clearfix spaceafter"></div>
<hr>
<div class="row-fluid editinstructions">
<?php
if (Yii::app()->user->fullname == "Lightspeed") {
}
?>
<?php
if (Yii::app()->user->fullname == "Lightspeed") {
echo "<p><strong>" . Yii::t('admin', 'To upload a new header image to add to your collection, drag and drop a file on top of the Choose File button, then click Upload. NOTE: You can also log into Admin Panel externally at {url} to use the Choose File button normally.', array('{url}' => $this->createAbsoluteUrl("/admin"))) . "</strong></p>";
} else {
echo Yii::t('admin', 'To upload a new header image to add to your collection, click Choose File and select your file, then click Upload.');
示例7: current
if ($model->selectedObjects) {
echo "margin-left: 260px;";
}
?>
width: 600px">
<?php
$firstExporter = current(array_keys($model->exporters));
?>
<div id="exporterType">
<fieldset>
<legend><?php
echo Yii::t('core', 'type');
?>
</legend>
<?php
echo CHtml::radioButtonList('Export[exporter]', $firstExporter, $model->exporters, array('separator' => ' '));
?>
</fieldset>
</div>
<div id="exporterSettings">
<?php
foreach ($model->exporterInstances as $exporter) {
?>
<div id="exporterSettings_<?php
echo get_class($exporter);
?>
">
<?php
echo $exporter->getSettingsView();
?>
</div>
示例8: array
}
?>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<?php
echo CHtml::link("<div id='smallcalendar' class='well'></div>", array('evento/index'));
?>
<div class="well" style='margin-top:30px; text-align:center;'>
<?php
foreach ($encuestas as $encuesta) {
$respuestas = OpcionesEncuesta::model()->findAll("estatus_did = 1 and encuesta_did = " . $encuesta->id);
if (count($respuestas) > 0) {
echo "<h3>" . $encuesta->nombre . "</h3>";
$respuestasArray = array();
$c = 0;
foreach ($respuestas as $respuesta) {
$respuestasArray[$c] = $respuesta->nombre;
$c++;
}
echo CHtml::hiddenField($encuesta->id, $encuesta->nombre);
echo CHtml::radioButtonList('choice', "selec", $respuestasArray, array('separator' => " "));
}
echo '<div class="col-lg-2 col-lg-offset-2">';
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Crear' : 'Guardar'));
echo '</div>';
}
?>
</div>
</div>
</div>
开发者ID:rzamarripa,项目名称:ase,代码行数:30,代码来源:index+(Copia+en+conflicto+de+MacBook+de+Zamarripa+2014-07-17).php
示例9: array
<?php
}
echo CHtml::beginForm(array('/order/create'), 'POST', array('id' => 'orderForm'));
?>
<?php
echo CHtml::hiddenField('delivery_address', 'address_value', array('id' => 'hide_address'));
?>
<div class="box">
<div class="box-title container_24">支付方式</div>
<div class="box-content" style="vertical-align:middle;">
<?php
$cri = new CDbCriteria(array('condition' => 'enabled = 1'));
$paymentMethod = PaymentMethod::model()->findAll($cri);
$list = CHtml::listData($paymentMethod, 'payment_method_id', 'name');
echo CHtml::radioButtonList('payment_method_id', '0', $list);
?>
</div>
</div>
<?php
$imageHelper = new ImageHelper();
?>
<div class="box">
<div class="box-title container_24">商品列表</div>
<div class="box-content cart container_24">
<table id="list-div-box" class="table">
<tr style="background:#F3F3F3;">
<th class="col-xs-3">图片</th>
<th class="col-xs-3">名称</th>
<th class="col-xs-3">属性</th>
示例10: CDbCriteria
</span>
</div>
<div class="nav btn-group background-color-5">
<div class="table-cell">
<div class="btn btn-small three-white-bars background-color-hover-6"></div>
</div>
<div class="table-cell full-width">
<div class="btn btn-large cursor-default text-left">支付方式</div>
</div>
</div>
<div class="checkout-payment-content background-color-0">
<?php
$cri = new CDbCriteria(array('condition' => 'enabled = 1'));
$paymentMethod = PaymentMethod::model()->findAll($cri);
$list = CHtml::listData($paymentMethod, 'id', 'name');
echo CHtml::radioButtonList('pay_method', '1', $list);
?>
</div>
<div class="nav btn-group background-color-5">
<div class="table-cell">
<div class="btn btn-small three-white-bars background-color-hover-6"></div>
</div>
<div class="table-cell full-width">
<div class="btn btn-large cursor-default text-left">购物车</div>
</div>
</div>
<table class="table-dark background-color-2">
<thead class="light-text background-color-6">
<tr>
<th class="text-center" style='width:150px'>编号</th>
<th class="text-center" style='width:150px'>图片</th>
示例11: array
?>
<?php
echo CHtml::activeTelField($model, 'request_name', array('placeholder' => Yii::t('sniper_ebay', 'Request')));
?>
<span class="required">*</span>
</div>
<?php
if (!$model->isNewRecord) {
?>
<div class="span6 offset2">
<div class="span3">
Request:
</div>
<?php
$request_types = array('new' => 'Create New', 'update' => 'Update Current');
echo CHtml::radioButtonList('request_type', 'update', $request_types, array('template' => '<span class="span4">{beginLabel}{input}{labelTitle}{endLabel}</span>', 'separator' => ' '));
?>
</div>
<?php
}
?>
</td>
</tr>
<tr>
<td>
<div class="span4">
<?php
//echo CHtml::textField('request[keyWord]', '', array('placeholder' => Yii::t('sniper_ebay', 'Keyword')));
?>
<?php
echo CHtml::activeTelField($model, 'keyword', array('placeholder' => Yii::t('sniper_ebay', 'Keyword'))) . ' <span class="required">*</span>';
示例12: array
<?php
echo CHtml::form(Yii::app()->request->url, 'post', array('onsubmit' => 'return submitForm(this);'));
?>
<div>
移动至
<strong>编号</strong>
<?php
echo CHtml::textField('target_id', '', array('size' => '6'));
?>
<?php
echo CHtml::radioButtonList('pos', '2', array('1' => '之前', '2' => '之后'), array('separator' => ' '));
?>
<?php
echo CHtml::submitButton('修改排序');
?>
</div>
<?php
echo CHtml::endForm();
?>
<script type="text/javascript">
function submitForm(f) {
targetId = $('#target_id').val();
if (targetId.length == 0) {
alert('请输入编号');
$('#target_id').focus();
return false;
示例13: foreach
//var_dump($products);die();
foreach ($products as $position => $product) {
if ($model = Products::model()->findByPk($product['product_id'])) {
$variations = '';
if (isset($product['Variations'])) {
foreach ($product['Variations'] as $specification => $variation) {
if ($specification = ProductSpecification::model()->findByPk($specification)) {
if ($specification->input_type == 'textfield') {
$variation = $variation[0];
} else {
$variation = ProductVariation::model()->findByPk($variation);
}
if (Shop::module()->allowPositionLiveChange) {
if ($specification->input_type == 'select') {
$name = sprintf('variation_%s_%s', $position, $specification->id);
$variations .= CHtml::radioButtonList($name, $variation->id, ProductVariation::listData($variation->getVariations(), true));
Yii::app()->clientScript->registerScript($name, "\r\n\t\t\t\t\t\t\t\t\t\t\$('[name=\"" . $name . "\"]').click(function(){\r\n\t\t\t\t\t\t\t\t\t\$.ajax({\r\n\t\t\t\t\t\t\t\t\t\t\t'url' : '" . CController::createUrl('//shop/shoppingCart/updateVariation') . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'type' : 'POST',\r\n\t\t\t\t\t\t\t\t\t\t\t'data' : \$(this),\r\n\t\t\t\t\t\t\t\t\t\t\terror: function() {\r\n\t\t\t\t\t\t\t\t\t\t\t\$('#amount_" . $position . "').css('background-color', 'red');\r\n\t\t\t\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\t\t\t\tsuccess: function(result) {\r\n\t\t\t\t\t\t\t\t\t\t\t\$('.amount_" . $position . "').css('background-color', 'lightgreen');\r\n\t\t\t\t\t\t\t\t\t\t\t\$('.widget_amount_" . $position . "').css('background-color', 'lightgreen');\r\n\t\t\t\t\t\t\t\t\t\t\t\$('.widget_amount_" . $position . "').html(\$('.amount_" . $position . "').val());\r\n\t\t\t\t\t\t\t\t\t\t\t\$('.price_" . $position . "').html(result);\t\r\n\t\t\t\t\t\t\t\t\t\t\t\$('.price_single_" . $position . "').load('" . $this->createUrl('//shop/shoppingCart/getPriceSingle?position=' . $position) . "');\r\n\t\t\t\t\t\t\t\t\t\t\t\$('.price_total').load('" . $this->createUrl('//shop/shoppingCart/getPriceTotal') . "');\r\n\t\t\t\t\t\t\t\t\t\t\t\$('.shipping_costs').load('" . $this->createUrl('//shop/shoppingCart/getShippingCosts') . "');\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\t\t\t\t\$('input:checked').trigger('click');\r\n\t\t\t\t\t\t\t\t\t\t");
$variations .= '<br />';
}
} else {
$variations .= $specification . ': ' . $variation . '<br />';
}
}
$img = CHtml::image(Yii::app()->baseUrl . '/' . $variation, '', array('width' => Shop::module()->imageWidthThumb));
}
}
printf('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td class="text-right price_single_' . $position . '">%s</td><td class="text-right price_' . $position . '">%s</td><td>%s</td></tr>', $img, CHtml::textField('amount_' . $position, $product['amount'], array('size' => 4, 'class' => 'amount_' . $position)), $model->title, $variations, Shop::priceFormat($model->getPrice($product['Variations'])), Shop::priceFormat($model->getPrice($product['Variations'], $product['amount'])), CHtml::link(Shop::t('Remove'), array('//shop/shoppingCart/delete', 'id' => $position), array('confirm' => Shop::t('Are you sure?'))));
Yii::app()->clientScript->registerScript('amount_' . $position, "\r\n\t\t\t\t\t\$('.amount_" . $position . "').keyup(function() {\r\n\t\t\t\t\t\t\$.ajax({\r\n\t\t\t\t\t\t\turl:'" . $this->createUrl('//shop/shoppingCart/updateAmount') . "',\r\n\t\t\t\t\t\t\tdata: \$('#amount_" . $position . "'),\r\n\t\t\t\t\t\t\tsuccess: function(result) {\r\n\t\t\t\t\t\t\t\$('.amount_" . $position . "').css('background-color', 'lightgreen');\r\n\t\t\t\t\t\t\t\$('.widget_amount_" . $position . "').css('background-color', 'lightgreen');\r\n\t\t\t\t\t\t\t\$('.widget_amount_" . $position . "').html(\$('.amount_" . $position . "').val());\r\n\t\t\t\t\t\t\t\$('.price_" . $position . "').html(result);\t\r\n\t\t\t\t\t\t\t\$('.price_total').load('" . $this->createUrl('//shop/shoppingCart/getPriceTotal') . "');\r\n\t\t\t\t\t\t\t\$('.shipping_costs').load('" . $this->createUrl('//shop/shoppingCart/getShippingCosts') . "');\r\n\r\n\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\terror: function() {\r\n\t\t\t\t\t\t\t\$('#amount_" . $position . "').css('background-color', 'red');\r\n\t\t\t\t\t\t\t},\r\n\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t\t\t\t");
}
}
if ($shippingMethod = Shop::getShippingMethod()) {
示例14:
<p>This is the game of Hangman. You must guess a word, a letter at a time.
If you make too many mistakes, you lose the game!</p>
<?php
echo CHtml::beginForm();
?>
<?php
echo CHtml::radioButtonList('level', null, $levels);
?>
<br/>
<?php
echo CHtml::submitButton('Play!');
?>
<?php
if ($error) {
?>
<span style="color:red">You must choose a difficulty level!</span>
<?php
}
?>
<?php
echo CHtml::endForm();
示例15: array
<?php
$this->breadcrumbs = array('商品中心' => array('index'), '管理');
$this->menu = array(array('label' => '创建商品', 'url' => array('create')));
?>
<h1>商品管理</h1>
<?php
$form = $this->beginWidget('CActiveForm', array('id' => 'item-form', 'action' => 'bulk', 'htmlOptions' => array('enctype' => 'multipart/form-data'), 'enableAjaxValidation' => false));
?>
<?php
$this->widget('zii.widgets.grid.CGridView', array('id' => 'item-grid', 'dataProvider' => $model->search(), 'selectableRows' => 2, 'filter' => $model, 'columns' => array(array('class' => 'CCheckBoxColumn', 'name' => 'id', 'value' => '$data->id'), array('name' => 'cate_id', 'value' => '$data->cat->cate_name'), 'item_name', 'item_sn', array('name' => 'if_show', 'value' => '$data->getShow()'), array('name' => 'is_tejia', 'value' => '$data->getTejia()'), array('name' => 'is_new', 'value' => '$data->getNew()'), array('name' => 'recommended', 'value' => '$data->getRecommend()'), 'sort_order', array('class' => 'CButtonColumn', 'header' => '操作', 'template' => '[{update}] [{delete}]', 'updateButtonImageUrl' => false, 'deleteButtonImageUrl' => false, 'htmlOptions' => array('width' => '63')))));
?>
<div class="row buttons" style="padding-top:10px">
<?php
echo CHtml::radioButtonList('act', '', array('delete' => '删除商品', 'if_show' => '上架商品', 'un_show' => '下架商品', 'is_tejia' => '设为特价', 'un_tejia' => '取消特价', 'is_new' => '设为新品', 'un_new' => '取消新品', 'recommended' => '推荐商品', 'un_recommended' => '取消推荐'), array('separator' => ' '));
?>
<?php
echo CHtml::submitButton('提交');
?>
</div>
<?php
$this->endWidget();