本文整理汇总了PHP中yii\helpers\Html::activeCheckbox方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::activeCheckbox方法的具体用法?PHP Html::activeCheckbox怎么用?PHP Html::activeCheckbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::activeCheckbox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
if (is_null($this->id)) {
if ($this->model instanceof Model) {
$this->id = Html::getInputId($this->model, $this->attribute);
} else {
$this->id = $this->getId();
}
}
if (is_null($this->name)) {
if ($this->model instanceof Model) {
$this->name = Html::getInputName($this->model, $this->attribute);
} else {
$this->name = $this->getId();
}
}
$this->options['id'] = $this->id;
$this->options['name'] = $this->name;
switch ($this->type) {
case 'checkbox':
if ($this->model instanceof Model) {
$this->options['label'] = null;
echo Html::activeCheckbox($this->model, $this->attribute, $this->options);
} else {
echo Html::checkbox($this->name, $this->checked, $this->options);
}
break;
case 'radio':
if ($this->model instanceof Model) {
$this->options['label'] = null;
echo Html::activeRadio($this->model, $this->attribute, $this->options);
} else {
echo Html::radio($this->name, $this->checked, $this->options);
}
break;
default:
throw new Exception('Invalid element type');
}
$this->register();
}
示例2: run
public function run()
{
$this->view->registerAssetBundle(MultiSelectAsset::className());
$options = $this->options;
if (isset($options['id'])) {
$id = $options['id'];
} else {
$id = BaseHtml::getInputId($this->model, $this->attribute);
}
if (isset($options['name'])) {
$name = $options['name'];
} elseif ($this->hasModel()) {
$name = BaseHtml::getInputName($this->model, $this->attribute);
} else {
$name = $this->name;
}
// if (isset($options['value'])) {
// $value = $options['value'];
// } elseif ($this->hasModel()) {
// $value = BaseHtml::getAttributeValue($this->model, $this->attribute);
// } else {
// $value = $this->value;
// }
$len = strlen($this->attribute);
$widget = Html::beginTag('div', ['id' => $id, 'name' => $name]);
foreach ($this->model as $k => $v) {
if (substr($k, 0, $len + 1) == $this->attribute . '_') {
$widget .= Html::activeCheckbox($this->model, $k, ['labelOptions' => ['class' => 'checkbox-inline']]);
}
}
$widget .= Html::endTag('div');
echo $widget;
}
示例3: run
/**
* @inheritdoc
*/
public function run()
{
$this->registerPlugin('iCheck');
if ($this->label) {
$this->options['label'] = $this->label;
}
if ($this->items) {
if (!($this->items = array_filter($this->items))) {
throw new InvalidValueException('Empty items list.');
}
}
if ($this->hasModel()) {
if ($this->items) {
$method = $this->type === static::TYPE_CHECKBOX ? 'activeCheckboxList' : 'activeRadioList';
$input = Html::$method($this->model, $this->attribute, $this->items, $this->options);
} else {
$input = Html::activeCheckbox($this->model, $this->attribute, $this->options);
}
} elseif ($this->items) {
$method = $this->type === static::TYPE_CHECKBOX ? 'checkboxList' : 'radioList';
$input = Html::$method($this->name, (bool) $this->value, $this->items, $this->options);
} else {
$input = Html::checkbox($this->name, (bool) $this->value, $this->options);
}
return $input;
}
示例4: run
/**
*
*/
public function run()
{
$view = $this->getView();
$this->registerScript($view);
if ($this->hasModel()) {
if ($this->label) {
$label = $this->label;
} else {
$label = Html::encode($this->model->getAttributeLabel(Html::getAttributeName($this->attribute)));
}
$tag = ArrayHelper::remove($this->textOptions, 'tag', 'span');
$text = Html::tag($tag, $label, $this->textOptions);
$this->options['label'] = $text;
$checkbox = Html::activeCheckbox($this->model, $this->attribute, $this->options);
} else {
$checkbox = Html::checkbox($this->name, $this->value, $this->options);
if ($this->label) {
$tag = ArrayHelper::remove($this->textOptions, 'tag', 'span');
$text = Html::tag($tag, $this->label, $this->textOptions);
$checkbox = Html::tag('label', $checkbox . ' ' . $text, $this->labelOptions);
}
}
$input = Html::tag('div', $checkbox, $this->containerOptions);
echo strtr($this->template, ['{input}' => $input]);
}
示例5: renderCheckboxInput
private function renderCheckboxInput()
{
if ($this->hasModel()) {
$input = Html::activeCheckbox($this->model, $this->attribute, $this->options);
} else {
$input = Html::checkbox($this->name, $this->checked, $this->options);
}
print $this->inlineLabel ? $input : Html::tag('div', $input);
}
示例6: run
/**
* Runs the widget
*
* @return string
*/
public function run()
{
$this->registerAssets();
if ($this->hasModel()) {
echo Html::activeCheckbox($this->model, $this->attribute, $this->options);
} else {
$checked = ArrayHelper::remove($this->options, 'checked', false);
echo Html::checkbox($this->name, $checked, $this->options);
}
}
示例7: run
/**
* @inheritdoc
*/
public function run()
{
if ($this->hasModel()) {
$input = Html::activeCheckbox($this->model, $this->attribute, $this->options);
} else {
$input = Html::checkbox($this->name, $this->checked, $this->options);
}
echo $this->inlineLabel ? $input : Html::tag('div', $input);
$this->selector = "#{$this->options['id']}";
$this->registerClientScript();
}
示例8: renderDataCellContent
/**
* @inheritdoc
*/
protected function renderDataCellContent($model, $key, $index)
{
/** @var $model ActiveRecord */
if ($this->format == 'boolean') {
return Html::activeCheckbox($model, $this->attribute, ['label' => false, 'class' => 'ajax-checkbox', 'data' => ['id' => $key, 'modelName' => $model->className(), 'attribute' => $this->attribute]]);
}
if ($this->content === null) {
return $this->grid->formatter->format($this->getDataCellValue($model, $key, $index), $this->format);
} else {
return parent::renderDataCellContent($model, $key, $index);
}
}
示例9: run
/**
* @inheritdoc
*/
public function run()
{
$option = array_merge(['label' => false, 'class' => 'make-switch'], $this->options);
if ($this->hasModel()) {
$input = Html::activeCheckbox($this->model, $this->attribute, $option);
} else {
$input = Html::checkbox($this->name, $this->checked, $option);
}
echo $this->inlineLabel ? $input : Html::tag('div', $input);
$this->selector = "#{$option['id']}";
$this->registerClientScript();
}
示例10: renderCheckbox
/**
* Renders the checkbox input
*/
public function renderCheckbox()
{
if ($this->inline == true) {
Html::addCssClass($this->_internalOptions, 'checkbox-custom checkbox-inline');
echo Html::beginTag('label', $this->_internalOptions) . "\n";
} else {
echo Html::beginTag('label', ['class' => 'checkbox-custom']) . "\n";
}
if ($this->hasModel()) {
echo Html::activeCheckbox($this->model, $this->attribute, $this->options) . "\n";
} else {
echo Html::checkbox($this->name, $this->value, $this->options) . "\n";
}
echo $this->label . "\n";
echo Html::endTag('label') . "\n";
}
示例11: checkbox
/**
* @param array $options
* @param bool|TRUE $enclosedByLabel
*
* @return $this
*/
public function checkbox($options = [], $enclosedByLabel = TRUE)
{
if ($enclosedByLabel) {
$this->parts['{input}'] = Html::activeCheckbox($this->model, $this->attribute, $options);
$this->parts['{label}'] = '';
} else {
if (isset($options['label']) && !isset($this->parts['{label}'])) {
$this->parts['{label}'] = $options['label'];
if (!empty($options['labelOptions'])) {
$this->labelOptions = $options['labelOptions'];
}
}
unset($options['labelOptions']);
$options['label'] = NULL;
$this->parts['{input}'] = Html::activeCheckbox($this->model, $this->attribute, $options);
}
$this->adjustLabelFor($options);
return $this;
}
示例12:
$fieldExtra = '';
if (!empty($model->errors['phone'])) {
$fieldExtra = 'has-feedback has-error';
}
echo Html::beginTag('div', ['class' => 'col-sm-6 form-group ' . $fieldExtra]);
echo Html::activeLabel($model, 'phone');
echo Html::activeTextInput($model, 'phone', ['class' => 'form-control']);
echo Html::error($model, 'phone', ['class' => 'help-inline text-danger']);
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'row']);
$fieldExtra = '';
if (!empty($model->errors['note'])) {
$fieldExtra = 'has-feedback has-error';
}
echo Html::beginTag('div', ['class' => 'col-sm-6 form-group ' . $fieldExtra]);
echo Html::activeLabel($model, 'note');
echo Html::activeTextArea($model, 'note', ['class' => 'form-control']);
echo Html::error($model, 'note', ['class' => 'help-inline text-danger']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-sm-6']);
echo Html::beginTag('div', ['class' => 'form-group ']);
echo Html::activeCheckbox($model, 'is_technical', []);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'form-group ']);
echo Html::activeCheckbox($model, 'is_billing', []);
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::endForm();
示例13:
" id="signin">
<?php
$form = ActiveForm::begin(['id' => 'login-form', 'options' => ['class' => 'form-signin'], 'fieldConfig' => ['template' => "{input}\n{error}"]]);
?>
<?php
echo $form->field($login, 'username')->textInput(['placeholder' => "Username"]);
?>
<?php
echo $form->field($login, 'password')->passwordInput(['placeholder' => 'Password']);
?>
<div class="form-group text-center">
<?php
echo Html::activeCheckbox($login, 'rememberMe');
?>
</div>
<div class="form-group">
<div class="col-lg-offset-1 col-lg-10">
<?php
echo Html::submitButton('Sign In', ['class' => 'btn btn-primary btn-block', 'name' => 'login-button']);
?>
</div>
</div>
<?php
ActiveForm::end();
?>
</div>
示例14:
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \common\models\LoginForm */
$this->title = 'Login';
$this->params['breadcrumbs'][] = $this->title;
$form = ActiveForm::begin(['id' => 'login-form', 'options' => ['class' => 'login-form']]);
?>
<h3 class="form-title">Sign In</h3>
<?php
echo $form->field($model, 'username')->textInput(['placeholder' => 'Username'])->label(false);
echo $form->field($model, 'password')->passwordInput(['placeholder' => 'Password'])->label(false);
?>
<div class="form-actions">
<?php
echo Html::submitButton('Login', ['class' => 'btn btn-success uppercase', 'name' => 'login-button']);
?>
<?php
echo Html::activeCheckbox($model, 'rememberMe', ['labelOptions' => ['class' => 'rememberme check']]);
?>
</div>
<?php
ActiveForm::end();
示例15: function
?>
<div class="estimate-index">
<h1><?php
echo Html::encode($this->title);
?>
</h1>
<div style="float: right">
<h3>Valor dólar: <?php
echo Currency::format(Currency::getUsToArs(), Currency::CURRENCY_ARS);
?>
</h3>
</div>
<p>
<?php
echo Html::a('Crear presupuesto', ['create'], ['class' => 'btn btn-success']);
?>
</p>
<?php
echo GridView::widget(['pjax' => true, 'pjaxSettings' => ['options' => ['id' => 'estimates-gridview']], 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'rowOptions' => function ($model, $index, $widget, $grid) {
return ['style' => "background-color:{$model->statusColor};"];
}, 'columns' => [['attribute' => 'id', 'label' => 'Número', 'options' => ['style' => 'width: 100px;']], ['label' => 'Cliente', 'value' => 'client.name', 'filter' => Html::activeTextInput($searchModel, 'clientName', ['class' => 'form-control'])], 'title', ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'status', 'label' => 'Estado', 'value' => 'statusLabel', 'filter' => Html::activeDropDownList($searchModel, 'status', Estimate::statusLabels(), ['class' => 'form-control', 'prompt' => 'Estado']), 'editableOptions' => ['inputType' => Editable::INPUT_DROPDOWN_LIST, 'data' => Estimate::statusLabels()], 'refreshGrid' => true, 'options' => ['style' => 'width: 160px;']], ['attribute' => 'request_date', 'format' => 'date', 'filter' => false, 'options' => ['style' => 'width: 125px;']], ['attribute' => 'sent_date', 'format' => 'date', 'filter' => false, 'options' => ['style' => 'width: 125px;']], ['label' => 'Muestra', 'filter' => Html::activeCheckbox($searchModel, 'sampleDelivered', ['label' => '']), 'value' => function ($model, $key, $index, $column) {
return $model->entriesWithSampleDeliveredCount > 0 ? 'Si' : 'No';
}, 'options' => ['style' => 'width: 70px;']], ['class' => 'yii\\grid\\ActionColumn', 'options' => ['style' => 'width: 60px;']]]]);
?>
</div>