当前位置: 首页>>代码示例>>PHP>>正文


PHP CHtml::checkBox方法代码示例

本文整理汇总了PHP中CHtml::checkBox方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::checkBox方法的具体用法?PHP CHtml::checkBox怎么用?PHP CHtml::checkBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CHtml的用法示例。


在下文中一共展示了CHtml::checkBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Widget's run function
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if ($this->hasModel()) {
         if ($this->form) {
             echo $this->form->checkBox($this->model, $this->attribute, $this->htmlOptions);
         } else {
             echo CHtml::activeCheckBox($this->model, $this->attribute, $this->htmlOptions);
         }
     } else {
         echo CHtml::checkBox($name, $this->value, $this->htmlOptions);
     }
     $this->registerClientScript($id);
 }
开发者ID:xunicorn,项目名称:ebay-simple-watching,代码行数:17,代码来源:TbSwitch.php

示例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');
     }
 }
开发者ID:sjnlabs2013,项目名称:sampleyii,代码行数:43,代码来源:JToggleSwitch.php

示例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;

		$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)?>&nbsp;<?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();
	}
开发者ID:nico13051995,项目名称:IntITA,代码行数:33,代码来源:AAFieldPassword.php

示例4: run

 public function run()
 {
     $output = '<div class="grid-view">
         <table class="items">
             <thead>
                 <tr>
                     <th>Menu</th>
                     <th>View</th>
                     <th>Create</th>
                     <th>Update</th>
                     <th>Delete</th>
                 </tr>
             </thead>
             <tbody>';
     $roles = Yii::app()->authManager->getRoles($this->user_id);
     $table = AdminAcl::getAllAclName();
     $count = 0;
     foreach ($table as $key => $types) {
         $count++;
         if ($count % 2 == 1) {
             $output .= '<tr class="odd">';
         } else {
             $output .= '<tr class="even">';
         }
         $output .= '<td style="text-align:left;">' . $key . '</td>';
         $output .= $this->appendRow(array_search('view', $types) !== false ? CHtml::checkBox($this->prefix . '[view_' . $key . ']', isset($roles['view_' . $key]), array('disabled' => $this->readonly)) : '');
         $output .= $this->appendRow(array_search('create', $types) !== false ? CHtml::checkBox($this->prefix . '[create_' . $key . ']', isset($roles['create_' . $key]), array('disabled' => $this->readonly)) : '');
         $output .= $this->appendRow(array_search('update', $types) !== false ? CHtml::checkBox($this->prefix . '[update_' . $key . ']', isset($roles['update_' . $key]), array('disabled' => $this->readonly)) : '');
         $output .= $this->appendRow(array_search('delete', $types) !== false ? CHtml::checkBox($this->prefix . '[delete_' . $key . ']', isset($roles['delete_' . $key]), array('disabled' => $this->readonly)) : '');
         $output .= '</tr>';
     }
     $output .= '</tbody></table></div>';
     echo $output;
 }
开发者ID:jasonhai,项目名称:onehome,代码行数:34,代码来源:CheckboxTableWidget.php

示例5: 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);
 }
开发者ID:snapfrozen,项目名称:snapcms,代码行数:28,代码来源:SnapActiveForm.php

示例6: run

    public function run()
    {
        //begin form
        echo CHtml::beginForm($this->action, $this->method, array('id' => $this->id, 'enctype' => $this->enctype, 'class' => $this->class));
        foreach ($this->model as $item) {
            if ($this->selector) {
                echo CHtml::checkBox('selector_' . $item['key']);
            }
            $name = Awecms::generateFriendlyName($item["key"]);
            ?>
            <div class="settings row">
                <?php 
            echo $this->getlabel($item['key']);
            switch ($item['type']) {
                //add new types here
                case 'textfield':
                    echo $this->getFullTextField($item);
                    break;
                case 'boolean':
                    echo CHtml::hiddenField($item['key'], 0);
                    echo CHtml::checkBox($item['key'], $item['value']);
                    break;
                case 'image_url':
                    echo $this->getFullTextField($item);
                    echo "<a class=\"right\" href=\"{$item["value"]}\" target=\"_blank\"><img src=\"{$item["value"]}\" title=\"{$name}\" alt=\"{$name}\" /></a>";
                    break;
                case 'email':
                    echo $this->getFullTextField($item);
                    break;
                case 'textarea':
                    echo CHtml::textArea($item['key'], $item['value']);
                case 'NULL':
                    break;
                default:
                    echo "Unsupported type: " . $item['type'] . " of " . $item['key'] . " with value " . $item['value'] . "<br/>";
                    break;
            }
            if (isset($item['hint'])) {
                ?>
                    <p class="hint">
                        <?php 
                echo $item['hint'];
                ?>
                    </p>
                    <?php 
            }
            ?>

            </div>
            <?php 
        }
        ?>
        <div class="row buttons">
            <?php 
        echo CHtml::submitButton('Submit!');
        ?>
        </div>
        <?php 
        echo CHtml::endForm();
    }
开发者ID:awecode,项目名称:awecms,代码行数:60,代码来源:EDynamicForm.php

示例7: renderHeader

 public function renderHeader()
 {
     echo CHtml::openTag('header', array('id' => 'header'));
     echo CHtml::openTag('div', array('class' => 'navbar navbar-fixed-top'));
     echo CHtml::openTag('div', array('class' => 'navbar-inner'));
     echo CHtml::openTag('a', array('class' => 'brand', 'style' => 'font-size:14px;margin-top:5px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;'));
     echo $this->model->getAttributeLabel('title');
     echo CHtml::textField('title', $this->model->title, array('style' => 'margin-left:36px;margin-bottom:0px;'));
     echo CHtml::closeTag('a');
     echo CHtml::openTag('a', array('class' => 'brand', 'style' => 'font-size:14px;margin-top:5px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;'));
     echo $this->model->getAttributeLabel('main_id') . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
     $this->widget('core.widgets.TTreeDropdown', array('treeId' => 'main_id', 'data' => HelpCategory::getHelpTree(), 'options' => array('view' => array('showLine' => false, 'showIcon' => true)), 'defaultText' => $this->model->main->name ? $this->model->main->name : '未分类', 'selectNode' => $this->model->main_id ? $this->model->main_id : ''));
     echo CHtml::closeTag('a');
     //置顶
     echo CHtml::openTag('a', array('class' => 'brand', 'style' => 'font-size:14px;margin-top:5px;margin-right:0px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;'));
     echo CHtml::checkBox('top', $checked = $this->model->top ? true : false, array('style' => 'margin-left:36px;margin-bottom:0px;margin-right:0px'));
     echo CHtml::closeTag('a');
     echo CHtml::openTag('a', array('class' => 'brand', 'style' => 'font-size:14px;margin-top:8px;margin-left:0px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;'));
     echo $this->model->getAttributeLabel('top');
     echo CHtml::closeTag('a');
     $this->controller->widget('bootstrap.widgets.TbButton', array('label' => '关闭', 'type' => 'primary', 'htmlOptions' => array('class' => 'pull-right', 'style' => 'margin-left:6px;', 'id' => 'btnCancel')));
     $this->controller->widget('bootstrap.widgets.TbButton', array('label' => '保存', 'type' => 'danger', 'htmlOptions' => array('style' => 'margin-left:6px;', 'class' => 'pull-right', 'id' => 'btnSave')));
     $this->controller->widget('bootstrap.widgets.TbButton', array('label' => '预览', 'htmlOptions' => array('class' => 'pull-right', 'id' => 'btnPrev')));
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('header');
 }
开发者ID:GsHatRed,项目名称:Yiitest,代码行数:27,代码来源:TMarkdownEditor.php

示例8: 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">&lt;a href=<?php echo $this->options['directoryPath']?>/</div>
		<?php
		echo CHtml::fileField(AutoAdmin::INPUT_PREFIX."[{$this->name}_new]", null, $tagOptions);

		return ob_get_clean();
	}
开发者ID:nico13051995,项目名称:IntITA,代码行数:34,代码来源:AAFieldFile.php

示例9: 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;
 }
开发者ID:yupe,项目名称:yupe,代码行数:37,代码来源:AttributeRender.php

示例10: 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));
     }
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:8,代码来源:RecordViewLayoutManager.php

示例11: getBattleCheckBox

 public static function getBattleCheckBox($name, $id, $container = 'div', $htmlOptions = array('class' => 'checkbox'))
 {
     if ($id === '') {
         return '';
     }
     $checkBox = CHtml::checkBox('ids', isset($_COOKIE['battle_' . $id]), array('class' => 'battle-person', 'data-id' => $id, 'data-name' => $name));
     $text = CHtml::tag('span', array(), Yii::t('common', 'Battle'));
     $label = CHtml::tag('label', array('class' => 'battle-label'), $checkBox . $text);
     return CHtml::tag($container, $htmlOptions, $label);
 }
开发者ID:sunshy360,项目名称:cubingchina,代码行数:10,代码来源:Persons.php

示例12: renderCheckbox

 public function renderCheckbox($name, array $metaData, $form = null)
 {
     $out = '';
     $id = $name;
     $value = isset($metaData['current']) ? (bool) $metaData['current'] : false;
     if (isset($metaData['label'])) {
         $out .= CHtml::label($metaData['label'], $id);
     }
     $out .= CHtml::checkBox($id, $value, array('id' => $id, 'form' => $form, 'container' => 'div', 'separator' => ''));
     return $out;
 }
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:11,代码来源:PluginSettingsHelper.php

示例13: renderField

 /**
  * Renders the input field
  */
 public function renderField()
 {
     $options = $this->buildOptions();
     echo \CHtml::openTag('div', $options);
     if ($this->hasModel()) {
         echo \CHtml::activeCheckBox($this->model, $this->attribute, $this->options);
     } else {
         echo \CHtml::checkBox($this->options['name'], $this->value, $this->options);
     }
     echo \CHtml::closeTag('div');
 }
开发者ID:abudayah,项目名称:yiiwheels-custom,代码行数:14,代码来源:SwitchButton.php

示例14: getField

 public function getField($widgetId, $rowGroupName = '', $rowIndex, $model, $attribute, $name, $value = '', $fieldClassName = '', $htmlOptions = array(), $hasError = false, $data = '', $params = '')
 {
     if ($hasError) {
         $fieldClassName = $fieldClassName . ' ' . CHtml::$errorCss;
     }
     $htmlOptions = ClonnableFields::addClass($htmlOptions, $fieldClassName);
     if (ClonnableFields::isModel($model)) {
         return CHtml::activeCheckBox($model, $attribute, $htmlOptions);
     } else {
         return CHtml::checkBox($name, (int) $value > 0, $htmlOptions);
     }
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:12,代码来源:TemplateCheckboxField.php

示例15: 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);
     }
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:12,代码来源:SendgridAccount.php


注:本文中的CHtml::checkBox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。