本文整理汇总了PHP中yii\bootstrap\Html::radio方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::radio方法的具体用法?PHP Html::radio怎么用?PHP Html::radio使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\bootstrap\Html
的用法示例。
在下文中一共展示了Html::radio方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getItem
/**
* @param null $options
* @param null $pluginOptions
*
* @return string
* @throws \Exception
*/
public function getItem($options = null, $pluginOptions = null)
{
switch ($this->type) {
case self::TYPE_TEXT:
return Html::input('text', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
case self::TYPE_EMAIL:
return Html::input('email', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
case self::TYPE_NUMBER:
return Html::input('number', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
case self::TYPE_TEXTAREA:
return Html::textarea('Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
case self::TYPE_COLOR:
return ColorInput::widget(['value' => $this->value, 'name' => 'Setting[' . $this->code . ']', 'options' => $options != null ? $options : ['class' => 'form-control']]);
case self::TYPE_DATE:
return DatePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['format' => 'yyyy-mm-dd', 'todayHighlight' => true]]);
case self::TYPE_TIME:
return TimePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['minuteStep' => 1, 'showSeconds' => true, 'showMeridian' => false]]);
case self::TYPE_DATETIME:
return DateTimePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => ['format' => 'yyyy-mm-dd H:i:s', 'todayHighlight' => true]]);
case self::TYPE_PASSWORD:
return PasswordInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['showMeter' => true, 'toggleMask' => false]]);
case self::TYPE_ROXYMCE:
return RoxyMceWidget::widget(['id' => 'Setting_' . $this->code, 'name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'action' => Url::to(['roxymce/default']), 'options' => $options != null ? $options : ['title' => $this->getName()], 'clientOptions' => $pluginOptions != null ? $pluginOptions : []]);
case self::TYPE_SELECT:
return Select2::widget(['value' => $this->value, 'name' => 'Setting[' . $this->code . ']', 'data' => $this->getStoreRange(), 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => ['allowClear' => true]]);
case self::TYPE_MULTI_SELECT:
$options['multiple'] = true;
if (!isset($options['class'])) {
$options['class'] = 'form-control';
}
return Select2::widget(['name' => 'Setting[' . $this->code . ']', 'value' => explode(",", $this->value), 'data' => $this->getStoreRange(), 'options' => $options, 'pluginOptions' => ['allowClear' => true]]);
case self::TYPE_FILE_PATH:
$value = Yii::getAlias($this->store_dir) . DIRECTORY_SEPARATOR . $this->value;
return FileInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $value, 'options' => $options != null ? $options : ['class' => 'form-control', 'multiple' => false], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['previewFileType' => 'any', 'showRemove' => false, 'showUpload' => false, 'initialPreview' => !$this->isNewRecord ? [$this->value] : []]]);
case self::TYPE_FILE_URL:
$value = $this->store_url . '/' . $this->value;
return FileInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['previewFileType' => 'any', 'showRemove' => false, 'showUpload' => false, 'initialPreviewAsData' => true, 'initialPreviewFileType' => self::fileType(pathinfo($this->value, PATHINFO_EXTENSION)), 'initialPreview' => !$this->isNewRecord ? $value : [], 'initialCaption' => $this->value]]);
case self::TYPE_PERCENT:
return RangeInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'html5Options' => ['min' => 0, 'max' => 100, 'step' => 1], 'options' => $options != null ? $options : ['class' => 'form-control'], 'addon' => ['append' => ['content' => '%']]]);
case self::TYPE_SWITCH:
$selector = explode(',', $this->store_range);
if (count($selector) != 2) {
throw new ErrorException(Yii::t('setting', 'Switch Field should have store with 2 value, and negative is first. Example: no,yes'), 500);
}
return Html::hiddenInput('Setting[' . $this->code . ']', $selector[0]) . SwitchInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $selector[1], 'containerOptions' => ['class' => 'nv-switch-container'], 'options' => $options != null ? $options : [], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['state' => $this->value == $selector[1], 'size' => 'small', 'offText' => ucfirst($selector[0]), 'onText' => ucfirst($selector[1])]]);
case self::TYPE_CHECKBOX:
$random = rand(1000, 9999);
return Html::checkboxList('Setting[' . $this->code . ']', explode(",", $this->value), $this->getStoreRange(), $options != null ? $options : ['class' => 'nv-checkbox-list checkbox', 'item' => function ($index, $label, $name, $checked, $value) use($random) {
$html = Html::beginTag('div');
$html .= Html::checkbox($name, $checked, ['id' => 'Setting_checkbox_' . $label . '_' . $index . '_' . $random, 'value' => $value]);
$html .= Html::label($label, 'Setting_checkbox_' . $label . '_' . $index . '_' . $random);
$html .= Html::endTag('div');
return $html;
}]);
case self::TYPE_RADIO:
$random = rand(1000, 9999);
return Html::radioList('Setting[' . $this->code . ']', $this->value, $this->getStoreRange(), $options != null ? $options : ['class' => 'nv-checkbox-list radio', 'item' => function ($index, $label, $name, $checked, $value) use($random) {
$html = Html::beginTag('div');
$html .= Html::radio($name, $checked, ['id' => 'Setting_radio_' . $label . '_' . $index . '_' . $random, 'value' => $value]);
$html .= Html::label($label, 'Setting_radio_' . $label . '_' . $index . '_' . $random);
$html .= Html::endTag('div');
return $html;
}]);
case self::TYPE_SEPARATOR:
return '<hr>';
default:
return Html::input('text', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
}
}
示例2:
echo Html::radio('source', false, ['value' => 'history']);
?>
</span>
<?php
echo Html::dropDownList('oldWorkName', null, $oldList, ['class' => 'form-control']);
?>
</div>
</div>
<div class="form-group">
<?php
echo Html::label('Выбрать из списка преподавателя');
?>
<div class="input-group ">
<span class="input-group-addon">
<?php
echo Html::radio('source', false, ['value' => 'list']);
?>
</span>
<?php
echo Html::dropDownList('listWorkName', null, $workList, ['class' => 'form-control']);
?>
</div>
</div>
<div class="form-group">
<div class="col-lg-12">
<?php
echo Html::submitButton('Сохранить', ['class' => 'btn btn-primary']);
?>
</div>
</div>
<?php
示例3: generateColumnByType
/**
* Ham tao giao dien cho column
* @param string $keyColumn ten truong cua column
* @param array $column mang setting cua column
* @param array $gallery mang gia tri cua image
* @param string $id id cua 1 anh
* @param string $tdOptions Html Attribute of td column
* @return string
*/
private function generateColumnByType($keyColumn, $column, $gallery, $id, $tdOptions = [], $module, $attribute)
{
$typeImage = ArrayHelper::getValue($column, 'displayType', 'text');
$items = ArrayHelper::getValue($column, 'items', []);
$options = ArrayHelper::getValue($column, 'options', ['class' => 'form-control']);
$column_name = $module . '[' . $attribute . '][' . $id . '][' . $keyColumn . ']';
switch ($typeImage) {
case self::SYA_TYPE_COLUMN_DROPDOWN:
$template = Html::dropDownList($column_name, ArrayHelper::getValue($gallery, $keyColumn), $items, $options);
break;
case self::SYA_TYPE_COLUMN_TEXTAREA:
$template = Html::textarea($column_name, ArrayHelper::getValue($gallery, $keyColumn), $options);
break;
case self::SYA_TYPE_COLUMN_RADIO:
$template = Html::radio($column_name, ArrayHelper::getValue($gallery, $keyColumn), $options);
break;
case self::SYA_TYPE_COLUMN_RADIOLIST:
$template = Html::radioList($column_name, ArrayHelper::getValue($gallery, $keyColumn), $items, $options);
break;
case self::SYA_TYPE_COLUMN_CHECKBOX:
$template = Html::checkbox($column_name, ArrayHelper::getValue($gallery, $keyColumn), $options);
break;
case self::SYA_TYPE_COLUMN_CHECKBOXLIST:
$template = Html::checkboxList($column_name, ArrayHelper::getValue($gallery, $keyColumn), $items, $options);
break;
case self::SYA_TYPE_COLUMN_HIDDEN:
$tdOptions = ArrayHelper::merge($tdOptions, ['style' => 'display: none;']);
$template = Html::hiddenInput($column_name, ArrayHelper::getValue($gallery, $keyColumn), $options);
break;
default:
$template = Html::textInput($column_name, ArrayHelper::getValue($gallery, $keyColumn), $options);
break;
}
$templateGallery = Html::beginTag('td', $tdOptions);
$templateGallery .= $template;
$templateGallery .= Html::endTag('td');
return $templateGallery;
}
示例4: function
?>
</button>
</div>
<div class="col-lg-12">
<hr>
</div>
<div class="col-lg-4">
<?php
echo \Yii::t('app', 'UNITS');
?>
</div>
<div class="col-lg-8">
<?php
echo Html::activeRadioList($model, 'units', ['mm' => 'mm', 'inch' => 'inch'], ['class' => 'btn-group', 'data' => ['toggle' => 'buttons'], 'item' => function ($index, $label, $name, $checked, $value) {
return '<label class="btn btn-default">' . Html::radio($name, $checked, ['value' => $value]) . $label . '</label>';
}]);
?>
</div>
<div class="col-lg-12">
<hr>
</div>
<div class="col-lg-4">
<?php
echo \Yii::t('app', 'OBSERVED PROPERTY');
?>
</div>
<div class="col-lg-8">
<?php
echo Html::activeDropDownList($model, 'property', ['Observation 1' => 'Observation 1', 'Observation 2' => 'Observation 2', 'Observation 3' => 'Observation 3', 'Observation 4' => 'Observation 4']);