本文整理汇总了PHP中CHtml::dropDownList方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::dropDownList方法的具体用法?PHP CHtml::dropDownList怎么用?PHP CHtml::dropDownList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::dropDownList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @inheritdoc
*/
public function run()
{
list($name, $id) = $this->resolveNameID();
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
if (isset($this->htmlOptions['name'])) {
$name = $this->htmlOptions['name'];
}
if ($this->type == static::TYPE_TEXT) {
if ($this->hasModel()) {
echo \CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
} else {
echo \CHtml::textField($name, $this->value, $this->htmlOptions);
}
} elseif ($this->type == static::TYPE_SELECT) {
if ($this->hasModel()) {
echo \CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
} else {
echo \CHtml::dropDownList($name, $this->value, $this->data, $this->htmlOptions);
}
} else {
throw new \CException("Invalid field type '{$this->type}'");
}
$options = !empty($this->options) ? \CJavaScript::encode($this->options) : '';
$script = "jQuery('#{$id}').select2({$options})";
foreach ($this->events as $event => $handler) {
$script .= ".on('{$event}'," . \CJavaScript::encode($handler) . ")";
}
$script .= ';';
\Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->getId(), $script);
$this->registerAssets();
}
示例2: renderContent
/**
* (non-PHPdoc)
* @see CPortlet::renderContent()
*/
protected function renderContent()
{
$themesList = array_combine(Yii::app()->themeManager->themeNames, Yii::app()->themeManager->themeNames);
echo CHtml::form('', 'post', array());
echo CHtml::dropDownList('themeSelector', Yii::app()->theme->name, $themesList, $this->dropDownOptions);
echo CHtml::endForm();
}
示例3: stoppage
public function stoppage()
{
//needs to have!
$months = array();
for ($i = 1; $i <= 12; $i++) {
$tmp = sprintf("%02d", $i);
$months[$tmp] = $tmp;
}
$years = array();
for ($i = 0; $i < 8; $i++) {
$tmp = sprintf("%02d", date("y") + $i);
$years[$tmp] = $tmp;
}
$monthSelect = CHtml::dropDownList('bill[mm]', 0, $months);
$yearSelect = CHtml::dropDownList('bill[yy]', 0, $years);
return '
<form id="billForm" method="post" action="' . Yii::app()->createUrl('/payment/bill') . '">
<input type="hidden" id="Payment_id" name="Payment[id]" value="' . $this->type . '">
<label>Card Number:</label>
<input id="billcreditCard" name="bill[creditCard]" />
<label>Expiration Date:</label>
' . $monthSelect . '/' . $yearSelect . '<br />
<label>CVV:</label>
<input id="billCvv2" name="bill[cvv2]" />
<label>ID:</label>
<input id="billId" name="bill[id]" />
<label>Sum:</label>
<input id="billTotal" name="bill[total]" readonly value="' . $this->sum . '">
<a href="javascript:sendBill();" class="btn btn-primary">Bill</a>
<div id=""></div>
</form>';
}
示例4: run
public function run()
{
if (!isset($this->htmlOptions['id'])) {
$this->htmlOptions['id'] = $this->id;
}
echo CHtml::dropDownList($this->name, $this->select, $this->data, $this->htmlOptions);
}
示例5: run
public function run()
{
list($name, $id) = $this->resolveNameID();
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
if (isset($this->htmlOptions['name'])) {
$name = $this->htmlOptions['name'];
} else {
$this->htmlOptions['name'] = $name;
}
$l = Language::loadConfig();
$data = array();
foreach ($l['languages'] as $k => $v) {
$data[$k] = Yii::t('languages', $v);
}
if ($this->empty) {
$data = array_merge(array('' => Yii::t('cms', $this->empty)), $data);
}
if ($this->hasModel()) {
echo CHtml::activeDropDownList($this->model, $this->attribute, $data, $this->htmlOptions);
} else {
echo CHtml::dropDownList($name, $this->value, $data, $this->htmlOptions);
}
}
示例6: actionGetCardsByCategory
/**
* Retrieves all cards in a particular category
* @param string $id The category id
*/
public function actionGetCardsByCategory($id = NULL)
{
if ($id === NULL) {
throw new CHttpException(400, Yii::t('Dashboard.main', 'Missing category id'));
}
$categories = Yii::app()->cache->get('cards_in_category');
if ($categories === false) {
$this->getCards();
$categories = Yii::app()->cache->get('cards_in_category');
}
$cards = $categories[$id];
$elements = $elementOptions = array();
// TODO: Fix multiple select
//$elementOptions['multiple'] = 'multiple';
foreach ($cards as $k => $card) {
$asset = Yii::app()->assetManager->publish(YiiBase::getPathOfAlias($card['path']), true, -1, YII_DEBUG);
$elements[] = $k;
$elementOptions['options'][] = array('value' => $k, 'data-img-src' => Yii::app()->getBaseUrl(true) . $asset . '/default.png');
}
$form = $this->beginWidget('ext.cii.widgets.CiiActiveForm', array('htmlOptions' => array('class' => 'pure-form pure-form-aligned item-selection-form')));
echo CHtml::openTag('div', array('class' => 'pure-form-group', 'style' => 'padding-bottom: 20px'));
echo CHtml::link(Yii::t('Dashboard.main', 'Add to Dashboard'), '#', array('id' => 'add-cards-button', 'class' => 'pure-button pure-button-link pure-button-primary pull-right pure-button-small', 'style' => 'position: absolute; top: 15px; right: 3%;'));
echo CHtml::tag('legend', array(), $id);
echo CHtml::dropDownList('card', NULL, $elements, $elementOptions);
echo CHtml::closeTag('div');
$this->endWidget();
}
示例7: run
public function run()
{
list($name, $id) = $this->resolveNameID();
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
if (isset($this->htmlOptions['name'])) {
$name = $this->htmlOptions['name'];
}
if (isset($this->settings['ajax'])) {
if (isset($this->model)) {
echo CHtml::textField($name, $this->model->{$this->attribute}, $this->htmlOptions);
} else {
echo CHtml::textField($name, $this->value, $this->htmlOptions);
}
} else {
if (isset($this->model)) {
echo CHtml::dropDownList($name, $this->model->{$this->attribute}, $this->data, $this->htmlOptions);
} else {
echo CHtml::dropDownList($name, $this->value, $this->data, $this->htmlOptions);
}
}
$this->registerScripts($id);
}
示例8: 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;
}
示例9: run
public function run()
{
list($this->name, $this->id) = $this->resolveNameId();
if (isset($this->htmlOptions['placeholder'])) {
$this->options['placeholder'] = $this->htmlOptions['placeholder'];
}
$data = array();
if (isset($this->options['placeholder'])) {
$data[''] = '';
}
$this->data = $data + $this->data;
if ($this->hasModel()) {
echo CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
} else {
$this->htmlOptions['id'] = $this->id;
echo CHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions);
}
$bu = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets/');
$cs = Yii::app()->clientScript;
$cs->registerCssFile($bu . '/select2.css');
if ($this->scriptPosition === null) {
$this->scriptPosition = $cs->coreScriptPosition;
}
$cs->registerScriptFile($bu . '/select2.js', $this->scriptPosition);
$options = $this->options ? CJavaScript::encode($this->options) : '';
$cs->registerScript(__CLASS__ . '#' . $this->id, "\$('#{$this->id}').select2({$options});");
}
示例10: procesarListaPartidos
private function procesarListaPartidos($postJugadorApi, $postJugadorLocal, $postTorneo, &$listaPartidos)
{
$selectTorneos = Torneo::model()->selectTorneos();
$peticionPartidos = ApiChallonge::getPartidoTorneo($postTorneo['idTorneo']);
$lengthJugadores = count($postJugadorApi);
for ($i = 0; $i < $lengthJugadores; $i++) {
$jugadorApi = $postJugadorApi[$i];
$jugadorLocal = $postJugadorLocal['jugadorId'][$i];
$idTorneoLocal = $postJugadorLocal['idTorneoVzla'];
$posicionJugadorLocal = $postJugadorLocal['posicionJugador'][$i];
$peticionPartidos = str_replace($jugadorApi, $jugadorLocal, $peticionPartidos);
$posicionJugador = new JugadorPosicionTorneo();
$posicionJugador->id_jugador = $jugadorLocal;
$posicionJugador->id_torneo = $idTorneoLocal;
$posicionJugador->posicion = $posicionJugadorLocal;
$posicionJugador->save();
}
$jsonPartidos = json_decode($peticionPartidos, true);
$i = 0;
foreach ($jsonPartidos as $key => $value) {
$match = $value['match'];
$player1Id = $match['player1_id'];
$player2Id = $match['player2_id'];
$winnerId = $match['winner_id'];
$ronda = $match['identifier'];
$numeroRonda = $match['round'];
$jugadorVzla1 = Jugador::model()->findByPk($player1Id);
$jugadorVzla2 = Jugador::model()->findByPk($player2Id);
$ganadorVzla = Jugador::model()->findByPk($winnerId);
$listaPartidos .= $this->renderPartial('_listaPartidos', array('jsonPartidos' => $jsonPartidos, 'player1Id' => $player1Id, 'player2Id' => $player2Id, 'winnerId' => $winnerId, 'ronda' => $ronda, 'numeroRonda' => $numeroRonda, 'jugadorVzla1' => $jugadorVzla1, 'jugadorVzla2' => $jugadorVzla2, 'ganadorVzla' => $ganadorVzla, 'i' => $i), true, false);
$i++;
}
$listaPartidos .= Chtml::label('ID Torneo SSBMVZLA', 'ResultadoPvP_idTorneoVzla') . '<br/>' . CHtml::dropDownList('ResultadoPvP[idTorneoVzla]', '', $selectTorneos, array('empty' => '')) . '<br/>';
}
示例11: renderPagerList
public function renderPagerList()
{
if (!$this->enablePagination) {
return;
}
if (isset($this->pagerlist['all'])) {
$t = $this->pagerlist;
$this->pagerlist = array();
foreach ($t as $k => $v) {
if ($k == 'all') {
$this->pagerlist[$this->dataProvider->getTotalItemCount()] = Yii::t('zii', $v);
} else {
$this->pagerlist[$k] = $v;
}
}
}
$controller = $this->getController();
$route = $controller->route;
$parameters = $_GET;
unset($parameters['pageSize']);
$parameters['page'] = $this->dataProvider->getPagination()->getCurrentPage() + 1;
$parameters['pageSize'] = '';
$url = $controller->createUrl($route, $parameters);
$id = parent::getId();
echo '<div class="' . $this->pagerlistCssClass . '">';
echo CHtml::dropDownList($id . '_pagerlist', $this->dataProvider->pagination->pageSize, $this->pagerlist, array('onchange' => $id . "_changePageSize(\"{$id}\",\"{$url}\")"));
echo '<span>' . Yii::t('zii', $this->textItemsPerPage) . '</span>';
echo '</div>';
}
示例12: run
public function run()
{
if (Yii::app()->user->isGuest) {
return;
}
$powerAdmin = array('sagittaros', 'yiseng', 'yugene');
$username = Yii::app()->user->id;
if (in_array($username, $powerAdmin)) {
$solr = new Solr('search-engine');
$res = $solr->query('id:"' . $this->dealUrl . '"');
$docs = $res->response->docs;
if (array_key_exists(0, $docs)) {
$options = array('Eateries' => 'Eateries', 'Fun & Activities' => 'Fun & Activities', 'Beauty & Wellness' => 'Beauty & Wellness', 'Goods' => 'Goods', 'Services & Others' => 'Services & Others', 'Travel' => 'Travel');
$ajaxScript = <<<EOD
jQuery.get('/admin/dealCrud/updateCategory',
{'id':'{$this->dealUrl}','category':jQuery(this).val()},
postUpdateCategoryAction
);
function postUpdateCategoryAction(data) {
if(data == 'SUCCESS'){
console.log("success");
alert('success');
} else {
console.log(data);
alert("update failed");
}
}
EOD;
$htmlOptions = array('onchange' => $ajaxScript);
echo CHtml::dropDownList('category', $res->response->docs[0]->category_raw, $options, $htmlOptions);
}
}
}
示例13: renderContent
/**
* (non-PHPdoc)
* @see CPortlet::renderContent()
*/
protected function renderContent()
{
$translations = self::getLanguagesList();
echo CHtml::form('', 'post', array());
echo CHtml::dropDownList('languageSelector', Yii::app()->getLanguage(), $translations, $this->dropDownOptions);
echo CHtml::endForm();
}
示例14: run
public function run()
{
Yii::app()->user->setState('pageSize', $this->mPageSize);
$this->mPageSize = null == $this->mPageSize ? $this->mDefPageSize : $this->mPageSize;
echo '# rows per page: ';
echo CHtml::dropDownList('pageSize', $this->mPageSize, $this->mPageSizeOptions, array('onchange' => "\$.fn.yiiGridView.update('{$this->mGridId}',{ data:{pageSize: \$(this).val() }})"));
}
示例15: renderVariation
function renderVariation($variation, $i)
{
if (!ProductSpecification::model()->findByPk(1)) {
return false;
}
if (!$variation) {
$variation = new ProductVariation();
$variation->specification_id = 1;
}
$str = '<tr> <td>';
$str .= CHtml::dropDownList("Variations[{$i}][specification_id]", $variation->specification_id, CHtml::listData(ProductSpecification::model()->findall(), "id", "title"), array('empty' => '-'));
$str .= '</td> <td>';
$str .= CHtml::textField("Variations[{$i}][title]", $variation->title);
$str .= '</td> <td>';
// Price adjustion
$str .= CHtml::dropDownList("Variations[{$i}][sign_price]", $variation->price_adjustion >= 0 ? '+' : '-', array('+' => '+', '-' => '-'));
$str .= '</td> <td>';
$str .= CHtml::textField("Variations[{$i}][price_adjustion]", abs($variation->price_adjustion), array('size' => 5));
// Weight adjustion
$str .= '</td> <td>';
$str .= CHtml::dropDownList("Variations[{$i}][sign_weight]", $variation->weight_adjustion >= 0 ? '+' : '-', array('+' => '+', '-' => '-'));
$str .= '</td> <td>';
$str .= CHtml::textField("Variations[{$i}][weight_adjustion]", abs($variation->weight_adjustion), array('size' => 5));
$str .= '</td> <td>';
for ($j = -10; $j <= 10; $j++) {
$positions[$j] = $j;
}
$str .= CHtml::dropDownList("Variations[{$i}][position]", $variation->position, $positions);
$str .= '</td></tr>';
return $str;
}