本文整理汇总了PHP中yii\helpers\Html::dropDownList方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::dropDownList方法的具体用法?PHP Html::dropDownList怎么用?PHP Html::dropDownList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::dropDownList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$this->registerPlugin('select2');
Html::addCssClass($this->options, 'form-control');
if ($this->hasModel()) {
return Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
} else {
return Html::dropDownList($this->name, $this->selection, $this->items, $this->options);
}
}
示例2: run
/**
* Executes the widget.
*/
public function run()
{
if ($this->hasModel()) {
echo Html::activeDropDownList($this->model, $this->attribute, $this->data, $this->options);
} else {
echo Html::dropDownList($this->name, $this->value, $this->data, $this->options);
}
MultiSelectAsset::register($this->view);
$this->registerPlugin('multiSelect');
}
示例3: renderDataCellContent
/**
* @inheritdoc
*/
protected function renderDataCellContent($model, $key, $index)
{
if (isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] .= 'editableCell form-control';
} else {
$this->htmlOptions['class'] = 'editableCell form-control';
}
// We need to number the submit attributes because data attribute is not case sensitive
$this->htmlOptions['data-submit-attributes'] = implode(',', $this->submitAttributes);
$i = 0;
foreach ($this->submitAttributes as $attribute) {
$this->htmlOptions['data-attribute' . $i] = $model[$attribute];
$i++;
}
$options = [];
if (is_array($this->dropDownOptions)) {
$options = $this->dropDownOptions;
} else {
$options = $model[$this->dropDownOptions];
}
$inputName = is_array($model) ? $this->attribute : Html::getInputName($model, $this->attribute);
$readonly = $this->readonly;
if (!is_bool($readonly)) {
$readonly = call_user_func($this->readonly, $model, $key, $index, $this);
}
if ($readonly) {
if (isset($options[$model[$this->attribute]])) {
return $options[$model[$this->attribute]];
}
return $model[$this->attribute];
}
return Html::dropDownList($inputName, $model[$this->attribute], $options, $this->htmlOptions);
}
示例4: run
public function run()
{
$view = $this->getView();
Select2Asset::register($view);
if ($this->value === '') {
$this->value = [];
}
if (!is_array($this->value)) {
$this->value[$this->value] = $this->value;
}
$tags = json_encode($this->tags);
echo Html::dropDownList($this->name, $this->value, $this->tags, ['class' => 'form-control', 'multiple' => true, 'id' => $this->options['id']]);
$script = <<<SCRIPT
\$("#{$this->options['id']}").select2({
placeholder: "{$this->placeholder}",
tags: {$tags},
})
SCRIPT;
if ($this->onChange) {
$script .= '.on("change", function(e){ $.ajax("' . $this->onChange . '&" + $("#' . $this->options['id'] . '").serialize());})';
}
if ($this->disabled) {
$script .= '.prop("disabled", true)';
}
$script .= ';';
$view = $this->getView();
$view->registerJs($script);
}
示例5: run
/**
* @inheritdoc
*/
public function run()
{
$timeZones = [];
$timeZonesOutput = [];
$now = new \DateTime('now', new \DateTimeZone('UTC'));
foreach (\DateTimeZone::listIdentifiers(\DateTimeZone::ALL) as $timeZone) {
$now->setTimezone(new \DateTimeZone($timeZone));
$timeZones[] = [$now->format('P'), $timeZone];
}
if ($this->sortBy == static::SORT_OFFSET) {
array_multisort($timeZones);
}
foreach ($timeZones as $timeZone) {
$content = preg_replace_callback("/{\\w+}/", function ($matches) use($timeZone) {
switch ($matches[0]) {
case '{name}':
return $timeZone[1];
case '{offset}':
return $timeZone[0];
default:
return $matches[0];
}
}, $this->template);
$timeZonesOutput[$timeZone[1]] = $content;
}
if ($this->hasModel()) {
echo Html::activeDropDownList($this->model, $this->attribute, $timeZonesOutput, $this->options);
} else {
echo Html::dropDownList($this->name, $this->selection, $timeZonesOutput, $this->options);
}
}
示例6: run
/**
* Renders the widget.
*/
public function run()
{
if ($this->hasModel()) {
return Html::activeDropDownList($this->model, $this->attribute, $this->_getItems(), $this->options);
} else {
return Html::dropDownList($this->name, $this->value, $this->_getItems(), $this->options);
}
}
示例7: renderPageSize
public function renderPageSize()
{
if (!$this->paginationPageSize || !count($this->paginationPageSize)) {
return '';
}
$content = Html::dropDownList('', self::getPaginationSize(), array_combine(array_values($this->paginationPageSize), $this->paginationPageSize), ['class' => 'pagination-size form-control']);
return $content;
}
示例8: renderDataCellContent
/**
* @inheritdoc
*/
protected function renderDataCellContent($model, $key, $index)
{
$attribute = $this->attribute;
$name = Html::getInputName($model, $attribute);
$value = $model->{$attribute};
$options = ArrayHelper::merge(['class' => $this->classPrefix . '-' . $attribute, 'data-id' => $key], $this->options);
return Html::dropDownList($name, $value, $model::$enum_category, $options);
}
示例9: renderDropDown
/**
* Render dropdown list
*/
public function renderDropDown()
{
if ($this->hasModel()) {
echo Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
} else {
echo Html::dropDownList($this->name, $this->value, $this->items, $this->options);
}
}
示例10: renderButtons
/**
* @return string
*/
protected function renderButtons()
{
$buttons = [self::ADD_ACTION => Html::button(Icon::show('plus') . ' ' . Yii::t('app', 'Add selected to:'), ['class' => isset($this->htmlOptions['add-class']) ? $this->htmlOptions['add-class'] : 'btn btn-default', 'disabled' => 'disabled', 'data-mc-action' => self::ADD_ACTION]), self::MOVE_ACTION => Html::button(Icon::show('arrows') . ' ' . Yii::t('app', 'Move selected to:'), ['class' => isset($this->htmlOptions['move-class']) ? $this->htmlOptions['move-class'] : 'btn btn-default', 'disabled' => 'disabled', 'data-mc-action' => self::MOVE_ACTION])];
$group = '';
foreach ($buttons as $id => $button) {
$group .= Html::tag('div', Html::tag('div', $button . "\n\t" . Html::tag('div', Html::dropDownList(null, null, static::$categories, ['prompt' => Yii::t('app', 'Select category'), 'class' => 'form-control', 'id' => $id]), ['class' => 'input-group']), ['class' => 'btn-group']), ['class' => 'col-xs-12 col-sm-6']);
}
return Html::tag('div', $group, ['class' => 'row m-bottom-10']);
}
示例11: run
public function run()
{
echo Html::beginForm(Url::to([$this->actionUrl]), 'post', []);
if (!empty($this->returnUrl)) {
echo Html::hiddenInput('returnUrl', $this->returnUrl);
}
echo Html::dropDownList('language', Yii::$app->language, Yii::$app->czaHelper->getEnabledLangs(), ['id' => $this->htmlId(), 'onchange' => 'this.form.submit()']);
echo Html::endForm();
}
示例12: renderPageDropDownList
protected function renderPageDropDownList()
{
$pageSizeList = [];
foreach ($this->pageSizeList as $value) {
$pageSizeList[$value] = $value;
}
//$linkurl = $this->pagination->createUrl($page);
return Html::dropDownList($this->pagination->pageSizeParam, $this->pagination->getPageSize(), $pageSizeList, $this->dropDownOptions);
}
示例13: run
public function run()
{
$this->registerJqueryPlugin('material_select');
if ($this->hasModel()) {
return Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
} else {
return Html::dropDownList($this->name, $this->value, $this->items, $this->options);
}
}
示例14: run
/**
* Render chosen select
* @return string|void
*/
public function run()
{
if ($this->hasModel()) {
echo Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
} else {
echo Html::dropDownList($this->name, $this->value, $this->items, $this->options);
}
$this->registerAssets();
}
示例15: run
/**
* @inheritdoc
*/
public function run()
{
$this->registerClientScript();
if ($this->hasModel()) {
return Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
} else {
return Html::dropDownList($this->name, $this->value, $this->items, $this->options);
}
}