本文整理汇总了PHP中CHtml::checkbox方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::checkbox方法的具体用法?PHP CHtml::checkbox怎么用?PHP CHtml::checkbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::checkbox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: field
private static function field($key, $value, $sModel, $model)
{
if (strpos($sModel, "listT(") === 0) {
$modelName = str_replace("listT(", "", $sModel);
$modelName = str_replace(")", "", $modelName);
$type = substr($modelName, strpos($modelName, '[') + 1, strpos($modelName, '[') - strpos($modelName, ']') + 1);
//echo $type;
//exit;
$modelName = str_replace("[" . $type . "]", "", $modelName);
$temp = CHtml::listData($modelName::model()->findAllByType($type), 'id', 'name');
$temp[''] = Yii::t('app', 'None');
//$label = Yii::t('app', $sModel->id) ;
$field = CHtml::dropDownList($model . '[' . $key . '][value]', $value, $temp) . "<br/>";
} elseif (strpos($sModel, "list(") === 0) {
$modelName = str_replace("list(", "", $sModel);
$modelName = str_replace(")", "", $modelName);
$temp = CHtml::listData($modelName::model()->findAll(), 'id', 'name');
$temp[''] = Yii::t('app', 'None');
//$label = Yii::t('app', $sModel->id) ;
$field = CHtml::dropDownList($model . '[' . $key . '][value]', $value, $temp) . "<br/>";
} elseif (strpos($sModel, "select(") === 0) {
$list = str_replace("select(", "", $sModel);
$list = CJSON::decode(str_replace(")", "", $list));
foreach ($list as &$item) {
//print $item;
$item = Yii::t('app', $item);
}
//$temp = CHtml::listData(CJSON::decode($list), 'id', 'name');
$temp[''] = Yii::t('app', 'None');
//$label = Yii::t('app', $sModel->id);
$field = CHtml::dropDownList($model . '[' . $key . '][value]', $value, $list) . "<br/>";
} elseif ($sModel == 'file') {
//$label = Yii::t('app', $sModel->id) ;
$field = CHtml::fileField($model . '[' . $key . '][value]', $value) . CHtml::hiddenField($model . '[' . $key . '][value]', $value) . "<a href='javascript:del();'>" . Yii::t('app', 'Delete') . "</a><br />";
} elseif ($sModel == 'boolean') {
//$label = Yii::t('app', $sModel->id);
$field = CHtml::hiddenField($model . '[' . $key . '][value]', false) . CHtml::checkbox($model . '[' . $key . '][value]', $value == 'true' ? true : false);
} elseif ($sModel == 'date') {
//$label = Yii::t('app', $sModel->id);
$field = CHtml::textField($model . '[' . $key . '][value]', $value, array('class' => 'date'));
$name = str_replace("[", "_", str_replace("]", "_", $model));
$field .= "<script>\njQuery('#{$name}{$key}_value').datepicker();</script>";
} else {
//$label = Yii::t('app', $sModel->id);
$field = CHtml::textField($model . '[' . $key . '][value]', $value);
}
return $field;
}
示例2: renderItemAssign
/**
* @desc render RBAC Item in context "Move"
* @param array $item
* @return string rendered RBAC Item
*/
public function renderItemAssign($child)
{
$colUsername = $this->colUsername;
$colUserid = $this->colUserid;
if (!$this->_user) {
throw new CHttpException("RBACDisplayHelper::_user is not set. Use setUser(object \$user)");
}
$urlPrefix = 'index.php?r=';
$item = $child['this'];
$out = "\n";
$types = $this->types;
// Manage Tree Header
$out .= '
<table id="rbacItem" ><tr>
<th width="10%" id="rbacItem' . $item->type . '" >' . $this->_displayName($child['this-name'], $item->type) . '</th>' . '<th width="5%" id="rbacItem" ><b>Type</b></th>' . '<th width="20%" id="rbacItem" ><b>Description</b></th>' . '<th width="20%" id="rbacItem" ><b>Buisness Rule</b></th>' . '<th width="5%" id="rbacItem" ><b>Data</b></th>
</tr>
';
$isAssigned = AuthAssignment::userIsAssigned($this->_user->{$colUserid}, $child['this-name']);
$checkBoxName = $isAssigned ? 'removeAssignments[]' : 'addAssignments[]';
$out .= '
<tr>
<td id="rbacItem" >' . CHtml::checkbox($checkBoxName, false, array('value' => $child['this-name'])) . ' ' . ($isAssigned ? '<span style="color:#ff0000">Eject</span>' : 'Assign') . '</td>' . '<td id="rbacItem" >' . $types[$item->type] . '</td>' . '<td id="rbacItem" >' . nl2br(CHtml::encode($item->description)) . '</td>' . '<td id="rbacItem" >' . nl2br(CHtml::encode($item->bizrule)) . '</td>' . '<td id="rbacItem" >' . nl2br(CHtml::encode($item->data)) . '</td></tr></table>';
return $out;
}
示例3: array
</div>
<br>
<div class="exportOption">
<?php
if (Yii::app()->params->isAdmin) {
echo CHtml::label(Yii::t('admin', 'Include Hidden Records?'), 'includeHidden');
echo CHtml::checkbox('includeHidden', false);
echo X2Html::hint2(Yii::t('admin', 'Include records that were hidden by the duplicate checker.'));
}
?>
</div>
<div class="exportOption">
<?php
echo CHtml::label(Yii::t('admin', 'Include Tags?'), 'includeTags');
echo CHtml::checkbox('includeTags', false);
?>
</div>
<?php
echo CHtml::button(Yii::t('app', 'Export'), array('class' => 'x2-button', 'id' => 'export-button'));
?>
<div id="status-text">
</div>
<div style="display:none" id="download-link-box">
<?php
echo Yii::t('admin', 'Please click the link below to download {model}.', array('{model}' => $model));
?>
示例4: generateColumnSelectorHtml
public function generateColumnSelectorHtml()
{
$this->columnSelectorHtml = CHtml::beginForm(array('/site/saveGvSettings'), 'get') . '<ul class="column-selector x2-dropdown-list' . ($this->fixedHeader ? ' fixed-header' : '') . '" id="' . $this->columnSelectorId . '">';
$i = 0;
foreach ($this->allFieldNames as $fieldName => &$attributeLabel) {
$i++;
$selected = array_key_exists($fieldName, $this->gvSettings);
$this->columnSelectorHtml .= "<li>" . CHtml::checkbox($this->namespacePrefix . 'columns[]', $selected, array('value' => $fieldName, 'id' => $this->namespacePrefix . 'checkbox-' . $i)) . CHtml::label($attributeLabel, $fieldName . '_checkbox') . "</li>";
}
$this->columnSelectorHtml .= '</ul></form>';
}
示例5: run
/**
* (non-PHPdoc)
* @see framework/CWidget::run()
*/
public function run()
{
$cs = Yii::app()->getClientScript();
list($name, $id) = $this->resolveNameID();
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
if (isset($this->htmlOptions['name'])) {
$name = $this->htmlOptions['name'];
} else {
$this->htmlOptions['name'] = $name;
}
if ($this->buttonType == 'buttonset') {
echo CHtml::closeTag($this->htmlTag);
$cs->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').buttonset();");
} else {
switch ($this->buttonType) {
case 'submit':
echo CHtml::submitButton($this->caption, $this->htmlOptions) . "\n";
break;
case 'button':
echo CHtml::htmlButton($this->caption, $this->htmlOptions) . "\n";
break;
case 'link':
echo CHtml::link($this->caption, $this->url, $this->htmlOptions) . "\n";
break;
case 'radio':
if ($this->hasModel()) {
echo CHtml::activeRadioButton($this->model, $this->attribute, $this->htmlOptions);
echo CHtml::label($this->caption, CHtml::activeId($this->model, $this->attribute)) . "\n";
} else {
echo CHtml::radioButton($name, $this->value, $this->htmlOptions);
echo CHtml::label($this->caption, $id) . "\n";
}
break;
case 'checkbox':
if ($this->hasModel()) {
echo CHtml::activeCheckbox($this->model, $this->attribute, $this->htmlOptions);
echo CHtml::label($this->caption, CHtml::activeId($this->model, $this->attribute)) . "\n";
} else {
echo CHtml::checkbox($name, $this->value, $this->htmlOptions);
echo CHtml::label($this->caption, $id) . "\n";
}
break;
default:
throw new CException(Yii::t('zii', 'The button type "{type}" is not supported.', array('{type}' => $this->buttonType)));
}
$options = empty($this->options) ? '' : CJavaScript::encode($this->options);
if (isset($this->onclick)) {
if (strpos($this->onclick, 'js:') !== 0) {
$this->onclick = 'js:' . $this->onclick;
}
$click = CJavaScript::encode($this->onclick);
$cs->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').button({$options}).click({$click});");
} else {
$cs->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').button({$options});");
}
}
}
示例6: array
<tr>
<th colspan=2>
<label for='attvisible' id='attvisible'>
<?php
$clang->eT('Attribute visible:');
?>
</label>
</th>
</tr>
<tr>
<td class='data'>
<?php
if ($attributes['visible'] == "TRUE") {
echo CHtml::checkbox('visible', TRUE, array('value' => 'TRUE', 'uncheckValue' => 'FALSE'));
} else {
echo CHtml::checkbox('visible', FALSE, array('value' => 'TRUE', 'uncheckValue' => 'FALSE'));
}
?>
</td>
<td class='actions'>
</td>
</tr>
</table>
<table width='400' id='ddtable' class='hovertable' style='display: none'>
<tr>
<th colspan='2'><?php
$clang->eT('Values:');
?>
</th>
</tr>
<?php
示例7: makeField
/**
* Echos or returns the file field, temp name hidden field, the delete checkbox and preview image and set up the uploadcare widget if used.
*
* @param CActiveForm $form the form in which the widget is called. Can be null if CActiveForm is not used. Defaults to null in parent class.
*
* @param boolean $return whether to return the html or just echo it. Defaults to false in parent class.
*
* @param string $attributePostName the fields name if non standard. Such as if using array notation. The format is [key1][key2][keyn...]attributeName, no class name. Defaults to null in parent class.
*
* @param array $fileFieldHtmlOptions html options for file field. Defaults to empty array in parent class.
*
* @param array $checkboxHtmlOptions html options for checkbox field. Defaults to empty array in parent class.
*
* @param array $previewImageHtmlOptions html options for preview image. Defaults to empty array in parent class.
*
* @return string the html.
*/
public function makeField($form, $attributePostName, $fileFieldHtmlOptions, $checkboxHtmlOptions, $previewImageHtmlOptions)
{
$behavior = $this->_behavior;
$owner = $behavior->owner;
$attribute = $behavior->attribute;
$ownerClass = get_class($owner);
$html = '';
if (isset($attributePostName)) {
$postAttributeArrays = substr($attributePostName, 0, strrpos($attributePostName, ']') + 1);
} else {
$postAttributeArrays = '';
}
foreach ($owner->behaviors() as $ownerBehaviorName => $ownerBehaviorParams) {
if (($ownerBehaviorParams['class'] == 'application.components.behaviors.UploadingBehavior.ActiveRecordUploadingBehavior' || $ownerBehaviorParams['class'] == 'application.components.behaviors.UploadingBehavior.ModelUploadingBehavior') && $ownerBehaviorParams['attribute'] == $behavior->attribute) {
$behaviorName = $ownerBehaviorName;
break;
}
}
$html .= '<div class="uploadFieldWrap">';
if ($owner->{$attribute} != '') {
if ($behavior->showPreviewImage) {
$html .= CHtml::image(Yii::app()->request->baseUrl . '/' . ($owner->{$behaviorName}->tempName != '' ? $owner->{$behaviorName}->tempDir . '/' . $this->fileSuffix($owner->{$behaviorName}->tempName, $behavior->previewImageSuffix) : $owner->{$behaviorName}->dir . '/' . $this->fileSuffix($owner->{$attribute}, $behavior->previewImageSuffix)), '', $previewImageHtmlOptions);
}
if ($behavior->allowDelete) {
$html .= CHtml::checkbox($ownerClass . $postAttributeArrays . '[' . $behaviorName . '][delete]', $behavior->delete, $checkboxHtmlOptions) . '<span>' . Yii::t('admin', 'Supprimer ou') . ' </span>';
}
$html .= CHtml::hiddenField($ownerClass . $postAttributeArrays . '[' . $behaviorName . '][tempName]', $behavior->tempName);
}
if ($behavior->uploadcare !== null) {
Yii::app()->clientScript->registerScript('UploadingBehaviorUploadCarePublicKey', "UPLOADCARE_PUBLIC_KEY = '" . $this->_uploadcareApi->getPublicKey() . "'; UPLOADCARE_LOCALE = '" . (isset($behavior->uploadcare['language']) ? $behavior->uploadcare['language'] : Yii::app()->language) . "';", CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->_uploadcareApi->widget->getScriptSrc(), CClientScript::POS_HEAD);
$options = array('role' => 'uploadcare-uploader');
$uploadcareArr = $behavior->uploadcare;
unset($uploadcareArr['publicKey']);
unset($uploadcareArr['privateKey']);
unset($uploadcareArr['language']);
$options = array_merge($options, $uploadcareArr);
if (!isset($options['data-images-only']) && isset($behavior->formats)) {
$options['data-images-only'] = 'true';
}
if (!isset($options['data-crop']) && isset($behavior->formats)) {
$options['data-crop'] = 'true';
}
$html .= CHtml::hiddenField($ownerClass . $postAttributeArrays . '[' . $attribute . ']', '', $options);
} else {
if ($form !== null) {
$html .= $form->fileField($owner, $postAttributeArrays . $attribute, $fileFieldHtmlOptions);
} else {
$html .= CHtml::activeFileField($owner, $postAttributeArrays . $attribute, $fileFieldHtmlOptions);
}
}
$html .= '</div>';
return $html;
}
示例8:
<?php
if (CCaptcha::checkRequirements()) {
?>
<div class="row captcha">
<div class="large-6 columns">
<?php
$this->widget('CCaptcha');
?>
<p>Please enter the letters as they are shown in the image above. Letters are not case-sensitive.</p>
</div>
<div class="large-6 columns">
<?php
echo CHtml::label('Subscribe to our mailing list', 'register');
?>
<?php
echo CHtml::checkbox('register', CHtml::value($_POST, 'register', true));
?>
</div>
</div>
<div class="row">
<div class="large-6 columns">
<?php
echo $form->labelEx($model, 'verify_code');
?>
<?php
echo $form->textField($model, 'verify_code');
?>
<?php
echo $form->error($model, 'verify_code');
?>
</div>
示例9: buildFormField
/**
* Parse each setting
*/
public function buildFormField($field, $userId)
{
$name = 'UserCustomField[' . $field->getKey() . ']';
$value = UserCustomFieldData::model()->getFieldValue($field, $userId);
switch ($field->type) {
case 'textarea':
echo CHtml::textArea($name, $value, array('rows' => 5, 'class' => 'textbox'));
break;
case 'dropdown':
echo CHtml::dropDownList($name, $value, $this->convertExtraToArray($field->extra), array('class' => 'chosen'));
break;
case 'multi':
echo CHtml::listBox($name, $value ? explode(',', $value) : '', $this->convertExtraToArray($field->extra), array('multiple' => 'multiple', 'class' => 'chosen'));
break;
case 'checkbox':
echo CHtml::checkbox($name, $value, array('class' => ''));
break;
case 'yesno':
echo CHtml::dropDownList($name, $value, array('0' => Yii::t('global', 'No'), '1' => Yii::t('global', 'Yes')), array('class' => 'chosen'));
break;
case 'editor':
Yii::app()->customEditor->getEditor(array('name' => $name, 'value' => $value));
break;
case 'text':
default:
echo CHtml::textField($name, $value, array('class' => 'textbox'));
break;
}
}
示例10: array
<div class="corners">
<?php
echo CHtml::textField('searchField', '', array('autocomplete' => 'off'));
?>
<img src="css/images/magnifier.png" alt="Search" onclick="jQuery('#search-form').submit();"></div>
<ul id="search">
<li>
<input id="cbxAll" type="checkbox" name="GlobalSearchForm[all]" value="1">
<?php
echo ECHtml::label(Yii::t('modules', 'all'), 'cbxAll');
?>
</li>
<?php
foreach ($this->getModulesToSearch() as $module) {
?>
<li>
<?php
echo CHtml::checkbox('GlobalSearchForm[' . $module->module_name . ']', false);
echo CHtml::label(Yii::t('modules', $module->module_name), 'GlobalSearchForm_' . $module->module_name);
?>
</li>
<?php
}
?>
</ul>
</li>
</ul>
<?php
$this->endWidget();
?>
</div>
示例11: getSettingForm
/**
* Parse each setting
*/
public function getSettingForm($setting)
{
$setting = $this->parseSetting($setting);
$name = 'setting_' . $setting->id;
$value = $setting->value !== null ? $setting->value : $setting->default_value;
switch ($setting->type) {
case 'textarea':
echo CHtml::textArea($name, $value, array('rows' => 5, 'class' => 'textbox', 'disabled' => $setting->disabled ? 'disabled' : ''));
break;
case 'dropdown':
echo CHtml::dropDownList($name, $value, $this->convertExtraToArray($setting->extra), array('class' => 'chzn-select', 'disabled' => $setting->disabled ? 'disabled' : ''));
break;
case 'multi':
echo CHtml::listBox($name, $value ? explode(',', $value) : '', $this->convertExtraToArray($setting->extra), array('size' => 20, 'multiple' => 'multiple', 'class' => 'chosen', 'disabled' => $setting->disabled ? 'disabled' : ''));
break;
case 'checkbox':
echo CHtml::checkbox($name, $setting->value != '' ? $setting->value : $setting->default_value, array('class' => '', 'disabled' => $setting->disabled ? 'disabled' : ''));
break;
case 'yesno':
echo CHtml::dropDownList($name, $value, array('0' => Yii::t('global', 'No'), '1' => Yii::t('global', 'Yes')), array('class' => 'chzn-select', 'disabled' => $setting->disabled ? 'disabled' : ''));
break;
case 'editor':
Yii::app()->customEditor->getEditor(array('name' => $name, 'value' => $value));
break;
case 'text':
default:
echo CHtml::textField($name, $value, array('class' => 'textbox', 'disabled' => $setting->disabled ? 'disabled' : ''));
break;
}
}
示例12: array
?>
</div>
<div class="cell">
<?php
echo CHtml::label(Yii::t('admin', 'Default View'), 'defaultView');
?>
<?php
echo CHtml::checkbox('defaultView', $defaultView);
?>
</div>
<div class="cell">
<?php
echo CHtml::label(Yii::t('admin', 'Default Form'), 'defaultForm');
?>
<?php
echo CHtml::checkbox('defaultForm', $defaultForm);
?>
</div>
<div class="cell right" style="padding-top:11px;">
<?php
echo CHtml::button(Yii::t('admin', 'Preview Mode'), array('id' => 'borderToggleButton', 'class' => 'x2-button right'));
?>
<?php
echo CHtml::submitButton(Yii::t('admin', 'Save'), array('class' => 'x2-button highlight right', 'style' => 'margin-right:5px;', 'id' => 'saveButton'));
?>
</div>
<?php
}
?>
</div>
</div>
示例13: foreach
<div class="section">
<h3 class="uk-h3"><?php
echo Yii::t("default", "Ingredients");
?>
</h3>
<?php
foreach ($data['ingredients'] as $val) {
?>
<?php
$item_data['ingredients_id'] = isset($item_data['ingredients_id']) ? $item_data['ingredients_id'] : '';
?>
<li>
<div class="price" id="price_wrap">
<span class="size">
<?php
echo CHtml::checkbox('ingredients[]', in_array($val, (array) $item_data['ingredients']) ? true : false, array('value' => $val));
?>
<?php
echo $val;
?>
</span>
</div>
</li>
<?php
}
?>
<div class="clear"></div>
</div>
<?php
}
示例14: array
<div class="control-group">
<label for="form-field-1" class="control-label">Date</label>
<div class="controls">
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => 'report_date', 'language' => strstr(Yii::app()->language . '_', '_', true), 'htmlOptions' => array('size' => 10), 'value' => $report_date, 'options' => array('showButtonPanel' => true, 'changeYear' => true, 'dateFormat' => 'yy.mm.dd')));
?>
</div>
</div>
<div class="control-group">
<label for="form-field-1" class="control-label">Excelis</label>
<div class="controls">
<?php
echo CHtml::checkbox('excel', false, array('id' => 'excel', 'class' => 'checkbox_class'));
?>
</div>
</div>
<div class="form-actions">
<?php
$this->widget("bootstrap.widgets.TbButton", array("label" => 'Create report', "icon" => "icon-ok bigger-110", "type" => "primary", "htmlOptions" => array("onclick" => "\$('#report-form').submit();")));
?>
</div>
<?php
$this->endWidget();
?>
</div>
示例15: isset
<?php
echo '<div style="width:600px;">';
?>
<?php
echo Yii::t('admin', 'Please click the button below to begin the export. Do not close this page until the export is finished, which may take some time if you have a large number of records. A counter will keep you updated on how many records have been successfully updated.');
?>
<br><br>
<?php
echo isset($listName) ? Yii::t('admin', 'You are currently exporting: ') . "<b>{$listName}</b>" : '';
?>
</div>
<br>
<?php
if (is_null($listId)) {
echo CHtml::label(Yii::t('admin', 'Include Hidden Records?'), 'includeHidden');
echo CHtml::checkbox('includeHidden', false);
}
?>
<?php
echo CHtml::button(Yii::t('app', 'Export'), array('class' => 'x2-button', 'id' => 'export-button'));
?>
<div id="status-text" style="color:green">
</div>
<div style="display:none" id="download-link-box">
<?php
echo Yii::t('admin', 'Please click the link below to download {model}.', array('{model}' => $model));
?>
<br><br>
<a class="x2-button" id="download-link" href="#"><?php