本文整理汇总了PHP中CHtml::checkBoxList方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::checkBoxList方法的具体用法?PHP CHtml::checkBoxList怎么用?PHP CHtml::checkBoxList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::checkBoxList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderField
/**
* @param $attribute
* @param null $value
* @param null $name
* @param array $htmlOptions
* @return mixed|null|string
*/
public static function renderField($attribute, $value = null, $name = null, $htmlOptions = [])
{
$name = $name ?: 'Attribute[' . $attribute->id . ']';
switch ($attribute->type) {
case Attribute::TYPE_SHORT_TEXT:
return CHtml::textField($name, $value, $htmlOptions);
break;
case Attribute::TYPE_TEXT:
return Yii::app()->getController()->widget(Yii::app()->getModule('store')->getVisualEditor(), ['name' => $name, 'value' => $value], true);
break;
case Attribute::TYPE_DROPDOWN:
$data = CHtml::listData($attribute->options, 'id', 'value');
return CHtml::dropDownList($name, $value, $data, array_merge($htmlOptions, ['empty' => '---']));
break;
case Attribute::TYPE_CHECKBOX_LIST:
$data = CHtml::listData($attribute->options, 'id', 'value');
return CHtml::checkBoxList($name . '[]', $value, $data, $htmlOptions);
break;
case Attribute::TYPE_CHECKBOX:
return CHtml::checkBox($name, $value, CMap::mergeArray(['uncheckValue' => 0], $htmlOptions));
break;
case Attribute::TYPE_NUMBER:
return CHtml::numberField($name, $value, $htmlOptions);
break;
case Attribute::TYPE_FILE:
return CHtml::fileField($name . '[name]', null, $htmlOptions);
break;
}
return null;
}
示例2: checkBoxList
public function checkBoxList($model, $attribute)
{
if ($model !== null) {
return CHtml::activeCheckBoxList($model, $attribute, $this->all);
} else
return CHtml::checkBoxList($attribute, '', $this->all);
}
示例3: 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();
}
示例4: explode
<label for='company_type'><?php
$clang->eT("Company Type* : ");
?>
</label>
</td>
<td>
<?php
$test = explode(',', $mrw['company_type_id']);
$test1 = explode(',', $mrw['company_type']);
$t = array_combine($test, $test1);
foreach ($t as $key => $val) {
$testkey[] = $key . '__' . $val;
}
$ctype = Company_type::model()->findAll(array('select' => 'concat(company_type_id,"__", company_type) as company_type_id , company_type_name', 'condition' => "Istitle = '1'"));
$ctypelist = CHtml::listData($ctype, 'company_type_id', 'company_type_name');
echo CHtml::checkBoxList('company_type', $testkey, $ctypelist, array('onChange' => 'javascript:hideshow(this.value,this.id)', 'required' => true));
?>
</td>
</tr>
<tr>
<td align="right" style="text-align: right; display: none">
<label for='IsListProvider'><?php
$clang->eT("IsListProvider : ");
?>
</label>
</td>
<td style="display: none">
<?php
echo CHtml::radioButtonList('IsListProvider', $mrw['is_list_provider'], array('1' => 'Yes', '0' => 'No'), array('separator' => ' '));
?>
</td>
示例5: array
}
}
$body = CHtml::checkBoxList('user_sys_ccmp_id', $aChecked, $list, array('labelOptions' => array('style' => 'display: inline'), 'template' => '{input}<span class="lbl"></span> {label}', 'class' => 'ace'));
$this->widget('AceBox', array('header_text' => UserModule::t('Sys companies'), 'body' => $body));
/**
* IP Tables
*/
$security_policy = Yii::app()->getModule('user')->SecurityPolicy;
if ($security_policy['useIpTables']) {
$aChecked = UxipUserXIpTable::model()->getUserIpTables($model->id);
$Iptb_list = IptbIpTable::model()->findAll();
$list = array();
foreach ($Iptb_list as $Iptb) {
$list[$Iptb['iptb_id']] = Yii::t('roles', $Iptb['iptb_name']);
}
$body = CHtml::checkBoxList('ip_tables', $aChecked, $list, array('labelOptions' => array('style' => 'display: inline'), 'template' => '{input}<span class="lbl"></span> {label}', 'class' => 'ace'));
$this->widget('AceBox', array('header_text' => UserModule::t('IP Tables'), 'body' => $body));
}
?>
<div class="btn-toolbar pull-left">
<div class="btn-group">
<?php
$this->widget("bootstrap.widgets.TbButton", array("label" => UserModule::t("Save"), "icon" => "icon-thumbs-up icon-white", "size" => "large", "type" => "primary", "htmlOptions" => array("onclick" => "\$('#user-rolls').submit();"), "visible" => Yii::app()->user->checkAccess("UserAdmin")));
?>
</div>
</div>
示例6: getPropCheckBoxListValues
public function getPropCheckBoxListValues($label = '', $selected = '', $class = '', $type = 'props', $child_type = '')
{
$cri = new CDbCriteria(array('condition' => 'prop_id =' . $this->prop_id, 'order' => 'sort_order asc, value_id asc'));
$PropValues = PropValue::model()->findAll($cri);
$list = CHtml::listData($PropValues, 'value_id', 'value_name');
foreach ($list as $k => $v) {
$data[$this->prop_id . ':' . $k] = $v;
}
echo '<ul class="sku-list">';
if ($child_type) {
echo CHtml::checkBoxList('Item[' . $type . '][' . $child_type . '][' . $this->prop_id . ']', $selected, $data, array('template' => '<label class="checkbox inline">{input}{label}</label>', 'label' => $label, 'separator' => '', 'class' => $class, 'labelOptions' => array('class' => 'labelForRadio')));
} else {
echo CHtml::checkBoxList('Item[' . $type . '][' . $this->prop_id . ']', $selected, $data, array('template' => '<label class="checkbox inline">{input}{label}</label>', 'label' => $label, 'separator' => '', 'class' => $class, 'labelOptions' => array('class' => 'labelForRadio')));
}
echo '</ul>';
}
示例7: array
<?php
$data = array();
foreach ($this->roles as $role) {
$data[$role->name] = $role->description;
}
$selected = array();
foreach ($this->currentRoles as $role) {
$selected[] = $role;
}
echo CHtml::checkBoxList('roles', $selected, $data);
示例8: array
$this->pageTitle = 'Vendor Care';
$form = $this->beginWidget('AdminForm', array('action' => $this->createUrl('vendorCare'), 'id' => 'vendor-care-filter-form', 'method' => 'get'));
$activeBranches = CHtml::listData(Branch::model()->active()->findAll(), 'bra_id', 'bra_title');
?>
<fieldset>
<div class="block-header">Search</div>
<div class="content">
<div class="control-group">
<label class="control-label">
Branch
<input type="checkbox" id="branch-trigger" checked="checked">
</label>
<div class="controls">
<?php
echo CHtml::checkBoxList('Deal[dea_branch]', isset($_GET['Deal']['dea_branch']) ? $_GET['Deal']['dea_branch'] : array_keys($activeBranches), $activeBranches, ['class' => 'branch-checkbox deal_branch', 'separator' => ' ']);
?>
</div>
<div class="block-buttons force-margin">
<?php
echo CHtml::submitButton('Search', ['class' => 'btn']);
?>
</div>
</div>
</div>
</fieldset>
<?php
$this->endWidget();
$this->widget('AdminGridView', array('title' => 'Vendor Care - Viewings', 'id' => 'vendor-care-list', 'dataProvider' => $dataProvider, 'afterAjaxUpdate' => 'reinstallDatePicker', 'columns' => array(array('name' => 'propertyAddress', 'header' => "Property", 'value' => function ($data) {
示例9: array
echo $form->textArea($model, 'company_description', array('class' => 'txtarea'));
?>
</li>
<li class="error_message"><?php
echo $form->error($model, 'company_description');
?>
</li>
</ul>
</fieldset>
<fieldset><legend>Deals In</legend>
<ul>
<li><span><label for="Property_description" class="required">Specialization <span class="required">*</span></label></span>
<div class="multi_checkbox avg">
<?php
$specialists = isset($_POST['specialist_type_id']) ? $_POST['specialist_type_id'] : null;
echo CHtml::checkBoxList('specialist_type_id', $specialists, CHtml::listData(Specializations::model()->findAll(), 'id', 'specialist'));
?>
</div>
</li>
<li class="error_message"><?php
echo $form->error($specialistType, 'specialist_type_id');
?>
</li>
</ul>
<?php
if (isset($_POST['city_id'])) {
$i = 0;
$data = 'City';
foreach ($_POST['city_id'] as $i => $location) {
if ($i > 0) {
$data = ' ';
示例10: CONCAT
<tr>
<td align="right" style="display: none;">
<label for='contact_type'><?php
$clang->eT("Contact Type* : ");
?>
</label>
</td>
<td style="display: none;">
<?php
$sql = "SELECT CONCAT(ctm.company_type_id,'__', ctm.company_type) AS company_type_id , company_type_name\n FROM {{map_company_n_types}} mct \n LEFT JOIN {{company_type_master}} ctm ON ctm.company_type_id = mct.company_type_id\n WHERE company_id =" . $mrw['company_id'] . "";
$uresult = Yii::app()->db->createCommand($sql)->query()->readAll();
$ctypelist = CHtml::listData($uresult, 'company_type_id', 'company_type_name');
foreach ($ctypelist as $key => $value) {
$test[] = $key;
}
echo CHtml::checkBoxList('company_type', $test, $ctypelist, array('required' => true));
?>
</td>
<td align="right" style="text-align: right;">
<?php
$ctypes = Company_type::model()->findAll(array('select' => 'concat(company_type_id,"__", company_type) as company_type_id , company_type_name', 'condition' => "company_type != 'O' AND IsTitle = '1'"));
$ctypeslist = CHtml::listData($ctypes, 'company_type_id', 'company_type_name');
foreach ($ctypelist as $key => $value) {
echo "<label id='titlelabel_" . $key . "'>Contact Title for " . $value . "* : </label>";
echo '<br/>';
}
?>
</td>
<td>
<?php
$titleselected = explode(',', $mrw['contact_title_id']);
示例11: array
<?php
echo CHtml::htmlButton('篩選條件', array('class' => 'search-button'));
?>
</td>
</tr>
</table>
<div class="search-form" style="display:none">
<?php
if (isset($serviceary)) {
echo CHtml::checkBoxList('qry_serviceno', $qry_serviceno, $serviceary, array('checkAll' => '全選', 'separator' => ' ', 'template' => '<div>{input} {label}</div>'));
}
?>
</div><!-- search-form -->
<?php
echo CHtml::endForm();
?>
</div><!-- form -->
</div>
<div class="tableBlue">
<table >
<tr>
<?php
for ($i = 0; $i < count($col); $i++) {
?>
示例12: run
//.........这里部分代码省略.........
if (!isset($page->user)) {
$page->user = Yii::app()->user->id;
}
?>
<div class="row">
<?php
echo $form->labelEx($page, 'user_id');
?>
<?php
echo $form->dropDownList($page, 'user', CHtml::listData(User::model()->findAll(), 'id', 'username'), array('prompt' => 'None'));
?>
<?php
echo $form->error($page, 'user_id');
?>
</div>
<?php
}
break;
case 'status':
?>
<div class="row">
<?php
echo $form->labelEx($page, 'status');
?>
<?php
echo CHtml::activeDropDownList($page, 'status', array('published' => Yii::t('app', 'Published'), 'trashed' => Yii::t('app', 'Trashed'), 'draft' => Yii::t('app', 'Draft')));
?>
<?php
echo $form->error($page, 'status');
?>
</div>
<?php
break;
case 'parent':
?>
<div class="row">
<?php
echo $form->labelEx($page, 'parent_id');
?>
<?php
$allModels = Page::findByType(get_class($this->model));
foreach ($allModels as $key => $aModel) {
if ($aModel->id == $page->id) {
unset($allModels[$key]);
}
}
echo $form->dropDownList($page, 'parent', CHtml::listData($allModels, 'id', 'title'), array('prompt' => 'None'));
?>
<?php
echo $form->error($page, 'parent_id');
?>
</div>
<?php
break;
case 'categories':
if (Yii::app()->hasModule('category')) {
?>
<div class="row nm_row">
<label for="categories"><?php
echo Yii::t('app', 'Categories');
?>
</label>
<?php
echo CHtml::checkBoxList('Page[categories]', array_map('Awecms::getPrimaryKey', $page->categories), CHtml::listData(Category::model()->findAll(), 'id', 'name'), array('attributeitem' => 'id', 'checkAll' => 'Select All'));
?>
</div>
<?php
}
break;
case 'tags':
?>
<div class="row">
<?php
if (Yii::app()->hasModule('tag')) {
Yii::app()->getController()->widget('TagWidget', array('model' => $page));
}
?>
</div>
<?php
break;
case 'comment_status':
?>
<div class="row">
<?php
echo $form->labelEx($page, 'Comments');
?>
<?php
echo $form->dropDownList($page, 'comment_status', array('enabled' => 'Enabled', 'disabled' => 'Disabled'));
?>
<?php
echo $form->error($page, 'comment_status');
?>
</div>
<?php
break;
default:
break;
}
}
}
示例13: explode
<?php
echo $form->error($model, 'logo_bg');
?>
</div>
</div>
<div class="clear"></div>
</div>
<div class="row">
<div class="label">
<?php
echo $form->labelEx($model, 'categories_id');
?>
</div>
<div class="field checkbox_list">
<?php
echo CHtml::checkBoxList('Categories[]', explode(',', $model->categories_id), Brands::model()->getCategoriesArray(), array('separator' => ' ', 'template' => '<span class="item">{input} {label}</span>'));
?>
<?php
echo $form->error($model, 'categories_id');
?>
</div>
</div>
<div class="row">
<div class="label">
<?php
echo $form->labelEx($model, 'text');
?>
</div>
<div class="field">
<?php
$this->widget('application.extensions.tinymce.ETinyMce', array('name' => get_class($model) . '[text]', 'value' => $model->getAttribute('text'), 'height' => '300px'));
示例14: array
$city = 'любой город';
$city_data = array('-1' => $city);
?>
<td align="left" valign="center" class="value">
<?php
echo CHtml::dropDownList('country_id', $country_id, $countries, array('class' => 'country_id', 'for' => '#city_id', 'fcselect' => "width:'411px'"));
?>
</td>
</tr>
<tr>
<td align="right" valign="center" class="label">
Города:
</td>
<td align="left" valign="center" class="value">
<?php
echo CHtml::checkBoxList('city', '', $city_data, array('container' => 'span class="checkBoxList" id="city_id" fcselect="width:\'411px\'"'));
?>
</td>
</tr>
<tr>
<td align="right" valign="center" class="label">
</td>
<td align="left" valign="center" class="hint">
Вы можете выбрать несколько городов
</td>
</tr>
<tr>
<td align="right" valign="center" class="label">
</td>
<td align="left" valign="center" class="header">
示例15: array
<?php
if ($model->isNewRecord) {
?>
<?php
echo $form->textFieldControlGroup($model, 'password', array('maxlength' => 255));
?>
<?php
}
?>
</div>
<div id="groups" class="tab-pane">
<div class="form-group">
<div class="col-lg-12">
<?php
echo CHtml::checkBoxList('UserGroups', CHtml::listData($userGroups, 'name', 'name'), CHtml::listData($groups, 'name', 'name'));
?>
</div>
</div>
</div>
</div>
</div>
<div id="sidebar" class="col-lg-3">
<?php
$this->beginWidget('bootstrap.widgets.BsPanel', array('title' => 'Menu', 'contentCssClass' => '', 'htmlOptions' => array('class' => 'panel sticky'), 'type' => BsHtml::PANEL_TYPE_PRIMARY));
?>
<div class="btn-group btn-group-vertical">
<?php
echo BsHtml::submitButton(BsHtml::icon(BsHtml::GLYPHICON_THUMBS_UP) . ' Save');