本文整理汇总了PHP中CHtml::label方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::label方法的具体用法?PHP CHtml::label怎么用?PHP CHtml::label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::label方法的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: run
public function run()
{
/*
<div class="switch-toggle switch-3 switch-ios large-9 columns" data="<?php echo $checked->accepted ?>">
<input id="DataItem_<?php echo $genId ?>_accepted_0" name="DataItem[<?php echo $genId ?>][accepted]" type="radio" value="1" <?php echo $checked->accepted==1?'checked':''?> />
<label for="DataItem_<?php echo $genId ?>_accepted_0" onclick="">Yes</label>
<input id="DataItem_<?php echo $genId ?>_accepted_1" name="DataItem[<?php echo $genId ?>][accepted]" type="radio" value="-1" <?php echo $checked->accepted==-1?'checked':''?> />
<label for="DataItem_<?php echo $genId ?>_accepted_1" onclick="">No</label>
<input id="DataItem_<?php echo $genId ?>_accepted_2" name="DataItem[<?php echo $genId ?>][accepted]" type="radio" value="0" <?php echo $checked->accepted==0?'checked':''?> />
<label for="DataItem_<?php echo $genId ?>_accepted_2" onclick="">N/A</label>
<a></a>
</div>
*/
$cs = Yii::app()->getClientScript();
$assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets');
$cs->registerCssFile($assets . DIRECTORY_SEPARATOR . 'toggle-switch.css');
$cs->registerScriptFile($assets . DIRECTORY_SEPARATOR . 'script.js', CClientScript::POS_BEGIN);
$nOfItems = count($this->data);
if ($this->type == 'switch-toggle') {
//You can add up to 5 items by using the .switch-3, .switch-4 and .switch-5 classes.
echo CHtml::openTag('div', array('class' => 'switch-toggle switch-' . $nOfItems . ' ' . $this->scheme . ' columns'));
foreach ($this->data as $key => $label) {
$checked = $this->selected == $key;
echo CHtml::radioButton($this->name, $checked, array('value' => $key, 'id' => $this->name . '_' . $key));
echo CHtml::label($label, $this->name . '_' . $key, array('onclick' => ''));
}
echo CHtml::tag('a', array(), '', true);
echo CHtml::closeTag('div');
}
if ($this->type == 'switch-light') {
echo CHtml::openTag('label', array('class' => 'switch-light ' . $this->scheme, 'onclick' => ''));
echo CHtml::checkBox('');
echo CHtml::openTag('span');
echo CHtml::tag('span', array(), 'Off');
echo CHtml::tag('span', array(), 'On');
echo CHtml::closeTag('span');
echo CHtml::tag('a', array(), '', true);
echo CHtml::closeTag('label');
}
}
示例3: formInput
public function formInput(&$controller, $tagOptions=array())
{
ob_start();
$inputName = $this->formInputName();
$inputID = "i_{$inputName}";
echo CHtml::label($this->label, $inputID);
echo CHtml::tag('br');
if($this->isReadonly)
$tagOptions['disabled'] = true;
if($this->value)
{
$oldOptions = array('readonly'=>true);
if($this->isReadonly)
$tagOptions['disabled'] = true;
echo CHtml::textField("{$inputName}[old]", $this->value, $oldOptions);
unset($oldOptions['readonly']);
?>
<label class="delfile">
<?php echo Yii::t('AutoAdmin.form', '<b class="warning">Delete</b> the file')?> <span class="tip">(<?php echo Yii::t('AutoAdmin.form', 'set checkbox on for confirm')?>)</span>:
<?php echo CHtml::checkBox("{$inputName}[del]", false, $oldOptions);?>
</label>
<?php
}
$tagOptions['id'] = $inputID;
echo CHtml::label(Yii::t('AutoAdmin.form', 'New file').':', $inputID);
?>
<div class="tip inline"><a href=<?php echo $this->options['directoryPath']?>/</div>
<?php
echo CHtml::fileField(AutoAdmin::INPUT_PREFIX."[{$this->name}_new]", null, $tagOptions);
return ob_get_clean();
}
示例4: fileField
public function fileField($model, $attribute, $htmlOptions = array())
{
$controlOptions = BsArray::popValue('controlOptions', $htmlOptions, array());
$labelOptions = BsArray::popValue('labelOptions', $htmlOptions, array());
$layout = $this->layout;
$output = '';
$output .= CHtml::activeFileField($model, $attribute, $htmlOptions);
$attr = $model->{$attribute};
if (!empty($attr)) {
//Special logic for ContentTypes
$tmpModel = $model;
if ($model instanceof ContentType) {
$tmpModel = $model->Content;
}
$output .= '<p class="file">' . CHtml::link($model->{$attribute}, array('/site/getFile', 'id' => $tmpModel->id, 'field' => $attribute, 'modelName' => get_class($tmpModel))) . '</p>';
$output .= '<div class="checkbox">' . CHtml::checkBox($attribute . '_delete');
$output .= CHtml::label('Delete?', $attribute . '_delete') . '</div>';
}
$htmlOptions['input'] = $output;
$htmlOptions['labelOptions'] = BsHtml::setLabelOptionsByLayout($layout, $labelOptions);
if (!empty($layout)) {
if ($layout === BsHtml::FORM_LAYOUT_HORIZONTAL) {
$controlClass = BsArray::popValue('class', $controlOptions, BsHtml::$formLayoutHorizontalControlClass);
BsHtml::addCssClass($controlClass, $htmlOptions['controlOptions']);
}
}
return BsHTML::activeTextFieldControlGroup($model, $attribute, $htmlOptions);
}
示例5: getMenuSubTitle
public function getMenuSubTitle()
{
return 'YII_DEBUG ' . CHtml::label( YII_DEBUG ? 'ON' : 'OFF',
null, array(
'style'=>sprintf('color:%s;',YII_DEBUG ? 'red':'green')
));
}
示例6: formInput
public function formInput(&$controller, $tagOptions=array())
{
ob_start();
$inputName = $this->formInputName();
$inputID = "i_{$inputName}";
echo CHtml::label($this->label, $inputID);
echo CHtml::tag('br');
if($this->isReadonly)
$tagOptions['disabled'] = true;
$tagOptions['id'] = $inputID;
if($this->value)
{
$tagOptions['value'] = 1;
?>
<div>
<?php echo Yii::t('AutoAdmin.form', '<span class="warning">Replace</span> password')?> (<?php echo Yii::t('AutoAdmin.form', 'set checkbox on for confirm')?>):
<br/><label><?php echo CHtml::checkBox("{$inputName}[is_new]", null, $tagOptions)?> <?php echo Yii::t('AutoAdmin.common', 'Yes')?></label>
</div>
<?php
echo CHtml::passwordField("{$inputName}[val]", '******', array('disabled'=>true));
}
else
{
if(!empty($this->options['pattern']))
$tagOptions['pattern'] = $this->options['pattern'];
if(isset($this->options['maxlength']))
$tagOptions['maxlength'] = $this->options['maxlength'];
echo CHtml::passwordField("{$inputName}[val]", $this->value, $tagOptions);
}
return ob_get_clean();
}
示例7: getViewActionMenuListItem
public static function getViewActionMenuListItem($modelId)
{
if (Yii::app()->controller->action->getId() === 'view') {
return array('name' => 'view', 'label' => Yii::t('app', 'View') . X2Html::minimizeButton(array('class' => 'record-view-type-menu-toggle'), '#record-view-type-menu', true, Yii::app()->params->profile->miscLayoutSettings['viewModeActionSubmenuOpen']), 'encodeLabel' => false, 'url' => array('view', 'id' => $modelId), 'linkOptions' => array('onClick' => '$(this).find ("i:visible").click ();'), 'itemOptions' => array('id' => 'view-record-action-menu-item'), 'submenuOptions' => array('id' => 'record-view-type-menu', 'style' => Yii::app()->params->profile->miscLayoutSettings['viewModeActionSubmenuOpen'] ? '' : 'display: none;'), 'items' => array(array('encodeLabel' => false, 'name' => 'journalView', 'label' => CHtml::checkBox('journalView', Yii::app()->params->profile->miscLayoutSettings['enableJournalView'], array('class' => 'journal-view-checkbox')) . CHtml::label(Yii::t('app', 'Journal View'), 'journalView')), array('encodeLabel' => false, 'name' => 'transactionalView', 'label' => CHtml::checkBox('transactionalView', Yii::app()->params->profile->miscLayoutSettings['enableTransactionalView'], array('class' => 'transactional-view-checkbox')) . CHtml::label(Yii::t('app', 'List View'), 'transactionalView'))));
} else {
return array('name' => 'view', 'label' => Yii::t('app', 'View'), 'encodeLabel' => true, 'url' => array('view', 'id' => $modelId));
}
}
示例8: groupForm
function groupForm($role)
{
ob_start();
?>
<table class="stdtable">
<tr>
<td>
<?php
echo CHtml::label(Yii::t('mc', 'Prefix'), 'prefix_' . $role);
?>
</td>
<td>
<?php
echo CHtml::label(Yii::t('mc', 'Suffix'), 'suffix_' . $role);
?>
</td>
<td>
<?php
echo CHtml::label(Yii::t('mc', 'Can Build'), 'build_' . $role);
?>
</td>
</tr>
<tr>
<td>
<?php
echo CHtml::textField('prefix_' . $role, @$_POST['prefix_' . $role]);
?>
</td>
<td>
<?php
echo CHtml::textField('suffix_' . $role, @$_POST['suffix_' . $role]);
?>
</td>
<td>
<?php
echo CHtml::dropDownList('build_' . $role, @$_POST['build_' . $role], array(0 => Yii::t('mc', 'Yes'), 1 => Yii::t('mc', 'No')));
?>
</td>
</tr>
<tr>
<td colspan="3">
<?php
echo CHtml::label(Yii::t('mc', 'Permissions, comma sepparated'), 'perms_' . $role);
?>
</td>
</tr>
<tr>
<td colspan="3">
<?php
echo CHtml::textField('perms_' . $role, @$_POST['perms_' . $role], array('style' => 'width: 540px'));
?>
</td>
</tr>
</table>
<?php
return ob_get_clean();
}
示例9: quickNoteSelector
public function quickNoteSelector(CFormModel $formModel)
{
ob_start();
ob_implicit_flush(false);
echo CHtml::label(Yii::t('app', 'Quick Note'), 'quickNote', array('style' => 'display:inline-block; margin-right: 10px;'));
echo X2Html::dropDownList('quickNote', '', array_merge(array('' => '-'), Dropdowns::getItems(117)), array('ajax' => array('type' => 'GET', 'url' => Yii::app()->controller->createUrl('/site/dynamicDropdown'), 'data' => 'js:{"val":$(this).val(),"dropdownId":"117"}', 'update' => $this->resolveIds('#quickNote2')), 'id' => $this->resolveId('quickNote'), 'class' => 'quick-note'));
echo X2Html::dropDownList('quickNote2', '', array('' => '-'), array('id' => $this->resolveId('quickNote2'), 'class' => 'quick-note'));
Yii::app()->clientScript->registerScript('quickNoteSelector', "\n \$('#{$this->resolveId('quickNote2')}').change (function () {\n \$(this).next ().val (\$(this).val ());\n });\n ");
return ob_get_clean();
}
示例10: renderInput
public function renderInput($attr)
{
switch ($attr) {
case 'password':
echo CHtml::activePasswordField($this, $attr, $this->htmlOptions($attr));
echo CHtml::label(Yii::t('app', 'Visible?'), 'visible', array('style' => 'display: inline'));
echo CHtml::checkBox('visible', false, array('id' => 'password-visible', 'onchange' => 'js: x2.credManager.swapPasswordVisibility("#Credentials_auth_password")'));
break;
default:
parent::renderInput($attr);
}
}
示例11: formInput
public function formInput(&$controller, $tagOptions=array())
{
ob_start();
$inputName = $this->formInputName();
echo CHtml::label($this->label, "{$inputName}[d]");
echo CHtml::tag('br');
if($this->isReadonly)
$tagOptions['disabled'] = true;
$d = $this->value ? $this->value : new DateTime(); //If not defined take current date
list($year, $month, $day) = explode('.', $d->format('Y.m.d'));
?>
<table class="time-panel"><tbody>
<tr>
<td class="calendar"><input type="text"/>
<?php
if(!empty($this->options['min']))
echo CHtml::tag('span', array('class'=>'mindate'), $this->options['min']);
if(!empty($this->options['max']))
echo CHtml::tag('span', array('class'=>'maxdate'), $this->options['max']);
?>
</td>
<td>
<?php
$days = array();
for($j = 1; $j <= 31; $j++)
$days[$j] = $j;
$tagOptions['id'] = "{$inputName}[d]";
echo CHtml::dropDownList("{$inputName}[d]", (int)$day, $days, $tagOptions);
?>
</td>
<td>
<?php
$tagOptions['id'] = "{$inputName}[m]";
$tagOptions['tabindex']++;
echo CHtml::dropDownList("{$inputName}[m]", (int)$month, Yii::app()->locale->getMonthNames(), $tagOptions);
?>
</td>
<td>
<?php
$tagOptions['id'] = "{$inputName}[y]";
$tagOptions['tabindex']++;
echo CHtml::textField("{$inputName}[y]", $year, $tagOptions, array_merge($tagOptions, array('maxlength'=>4, 'class'=>'i-year')));
?>
</td>
</tr>
</tbody></table>
<?php
return ob_get_clean();
}
示例12: getModuleParamRow
/**
* Формирует поле для редактирование параметра модуля
* @param \yupe\components\WebModule $module
* @param $param
* @return string
*/
private function getModuleParamRow(\yupe\components\WebModule $module, $param)
{
$editableParams = $module->getEditableParams();
$moduleParamsLabels = CMap::mergeArray($module->getParamsLabels(), $module->getDefaultParamsLabels());
$res = CHtml::label($moduleParamsLabels[$param], $param);
/* если есть ключ в массиве параметров, то значит этот параметр выпадающий список в вариантами */
if (array_key_exists($param, $editableParams)) {
$res .= CHtml::dropDownList($param, $module->{$param}, $editableParams[$param], ['class' => 'form-control', 'empty' => Yii::t('YupeModule.yupe', '--choose--')]);
} else {
$res .= CHtml::textField($param, $module->{$param}, ['class' => 'form-control']);
}
return $res;
}
示例13: renderButtons
/**
* Returns the formatted button
* @return string the resulting HTML
*/
public function renderButtons()
{
list($name, $id) = $this->resolveNameID();
$buttons = array();
$checked = $this->hasModel() ? !$this->model->{$this->attribute} : true;
$buttons[] = \CHtml::radioButton($name, $checked, array('id' => $id . '_on', 'value' => 1));
$buttons[] = \CHtml::label($this->offLabel, $id . '_on');
$checked = $checked ? false : true;
$buttons[] = \CHtml::radioButton($name, $checked, array('id' => $id . '_off', 'value' => 1));
$buttons[] = \CHtml::label($this->onLabel, $id . '_off');
$buttons[] = '<span></span>';
return \CHtml::tag('div', $this->htmlOptions, implode("\n", $buttons));
}
示例14: formInput
public function formInput(&$controller, $tagOptions=array())
{
ob_start();
$inputName = $this->formInputName();
$inputID = "i_{$inputName}";
echo CHtml::label($this->label, $inputID);
echo CHtml::tag('br');
if($this->isReadonly)
$tagOptions['disabled'] = true;
$tagOptions['id'] = $inputID;
echo CHtml::checkBox($inputName, (bool)(isset($this->value) ? $this->value : $this->defaultValue), $tagOptions);
return ob_get_clean();
}
示例15: run
public function run()
{
$model = $this->model;
$cities = $this->cities;
$locations = $model->locations;
if (empty($locations)) {
$location = new CompetitionLocation();
$locations = array($location->attributes);
}
//tab
echo CHtml::openTag('ul', array('class' => 'nav nav-tabs', 'role' => 'tablist'));
foreach ($locations as $key => $location) {
$index = $key + 1;
echo CHtml::tag('li', array('class' => $key == 0 ? 'active' : ''), CHtml::tag('a', array('href' => '#location-' . $index, 'role' => 'tab', 'data-toggle' => 'tab'), '地址' . $index . ($key == 0 ? '<span class="required">*</span></a>' : '')));
}
echo '<li><a id="addLocation"><i class="fa fa-plus"></i> 添加</a></li>';
echo CHtml::closeTag('ul');
echo '<div class="text-danger col-lg-12">地址1必填,除非多地点比赛,否则请只填写一个地址,留空即可删去多余地址。</div>';
//tab content
echo CHtml::openTag('div', array('class' => 'tab-content locations'));
foreach ($locations as $key => $location) {
$index = $key + 1;
echo CHtml::openTag('div', array('class' => 'tab-pane location' . ($key == 0 ? ' active' : ''), 'id' => 'location-' . $index));
echo Html::formGroup($model, 'locations[province_id][]', array('class' => 'col-lg-6'), CHtml::label('省份', false), CHtml::dropDownList(CHtml::activeName($model, 'locations[province_id][]'), $location['province_id'], Region::getProvinces(false), array('class' => 'form-control province', 'prompt' => '')), CHtml::error($model, 'locations.province_id.' . $key, array('class' => 'text-danger')));
echo Html::formGroup($model, 'locations[city_id][]', array('class' => 'col-lg-6'), CHtml::label('城市', false), CHtml::dropDownList(CHtml::activeName($model, 'locations[city_id][]'), $location['city_id'], isset($cities[$location['province_id']]) ? $cities[$location['province_id']] : array(), array('class' => 'form-control city', 'prompt' => '')), CHtml::error($model, 'locations.city_id.' . $key, array('class' => 'text-danger')));
echo Html::formGroup($model, 'locations[venue_zh][]', array('class' => 'col-lg-12'), CHtml::label('中文地址', false), CHtml::textField(CHtml::activeName($model, 'locations[venue_zh][]'), $location['venue_zh'], array('class' => 'form-control')), CHtml::error($model, 'locations.venue_zh.' . $key, array('class' => 'text-danger')));
echo Html::formGroup($model, 'locations[venue][]', array('class' => 'col-lg-12'), CHtml::label('英文地址', false), CHtml::textField(CHtml::activeName($model, 'locations[venue][]'), $location['venue'], array('class' => 'form-control')), CHtml::error($model, 'locations.venue.' . $key, array('class' => 'text-danger')));
echo CHtml::closeTag('div');
}
echo CHtml::closeTag('div');
Yii::app()->clientScript->registerScript('MultiLocations', <<<EOT
\$(document).on('click', '#addLocation', function() {
var location = \$('.location:last').clone();
var index = \$('.location').length + 1;
var tab = \$('<a role="tab" data-toggle="tab">').attr('href', '#location-' + index).text('地址' + index);
location.appendTo(\$('.locations'));
location.find('.province').val('').trigger('change');
location.find('input').val('');
location.attr('id', 'location-' + index).removeClass('active');
\$('<li>').append(
tab
).insertBefore(\$('#addLocation').parent());
tab.tab('show');
});
EOT
);
}