本文整理汇总了PHP中CHtml::listBox方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::listBox方法的具体用法?PHP CHtml::listBox怎么用?PHP CHtml::listBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::listBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$type = DataType::getInputType($this->column->dbType);
$this->htmlOptions += $this->fixedHtmlOptions[$type];
$column = $this->column->name;
$name = isset($this->htmlOptions['name']) ? $this->htmlOptions['name'] : 'Row[' . $column . ']';
switch ($type) {
case 'number':
echo CHtml::activeTextField($this->row, $column, $this->htmlOptions);
break;
case 'select':
echo CHtml::activeDropDownList($this->row, $column, $this->getEnumValues(), $this->htmlOptions);
break;
case 'select-multiple':
#echo CHtml::activeListBox($this->row, $column, $this->getSetValues(), $this->htmlOptions);
echo CHtml::listBox($name, $this->row->getAttributeAsArray($column), $this->getSetValues(), $this->htmlOptions);
break;
case 'text':
echo CHtml::activeTextArea($this->row, $column, $this->htmlOptions);
break;
case 'file':
echo '<script type="text/javascript">
$(document).ready(function() {
$("# echo CHtml::$idPrefix; ?>").submit(function() {
alert("ok1");
});
});
</script>';
echo CHtml::activeFileField($this->row, $column, $this->htmlOptions);
break;
case 'date':
$this->SetDateTimeHtmlOptions($column);
echo CHtml::activeTextField($this->row, $column, $this->htmlOptions);
echo '<script type="text/javascript">
$(document).ready(function() {
$("#' . $this->htmlOptions['id'] . '").datepicker({showOn: "button", dateFormat: "yy-mm-dd", buttonImage: "' . ICONPATH . '/16/calendar.png' . '", buttonImageOnly: true, buttonText: "' . Yii::t('core', 'showCalendar') . '"});
});
</script>';
break;
case 'datetime':
$this->SetDateTimeHtmlOptions($column);
echo CHtml::activeTextField($this->row, $column, $this->htmlOptions);
echo '<script type="text/javascript">
$(document).ready(function() {
now = new Date();
$("#' . $this->htmlOptions['id'] . '").datepicker({showOn: "button", dateFormat: "yy-mm-dd " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds(), buttonImage: "' . ICONPATH . '/16/calendar.png' . '", buttonImageOnly: true, buttonText: "' . Yii::t('core', 'showCalendar') . '"});
});
</script>';
break;
default:
echo CHtml::activeTextField($this->row, $column, $this->htmlOptions);
break;
}
}
示例2: array
echo '</div>';
echo CHtml::endForm();
?>
<?php
$this->endWidget();
?>
</div>
<div class="span6">
<?php
$this->beginWidget('zii.widgets.CPortlet', array('title' => "Text fields"));
?>
<?php
echo CHtml::label('List box', 'name');
echo CHtml::listBox('name', '', array('1' => 'One', '2' => 'Two', '3' => 'Three', '4' => 'Four', '5' => 'Five'));
echo CHtml::label('Text Area', 'name');
echo CHtml::textArea('name');
echo CHtml::label('File field', 'name');
echo CHtml::fileField('name', '', array('class' => 'btn'));
echo CHtml::label('Radio button', 'name');
echo CHtml::radioButton('name');
echo '<br><br>';
echo CHtml::label('Check box', 'name');
echo CHtml::checkBox('name');
?>
<?php
$this->endWidget();
?>
</div>
</div>
示例3: __toString
public function __toString()
{
$input = "";
if (is_string($this->field)) {
return "[{$this->field}]";
}
if (!isset($this->dateformat) || $this->dateformat == '') {
$this->dateformat = 'dd/mm/yy';
}
if (!in_array($this->field->uicomponent, array("textbox", "textarea", "listbox", "combobox", "checkbox", "datebox"))) {
return "[invalid: " . $this->field->uicomponent . "]";
}
if (!in_array($this->descriptionLocation, array('visible', 'title'))) {
$this->descriptionLocation = 'title';
}
$descrVisibleTag = '';
if ($this->descriptionLocation == 'visible') {
$descrVisibleTag = "<div class='descr'>{$this->descr}</div>";
}
if ($this->descriptionLocation == 'title') {
if (!isset($this->htmlOptions['title'])) {
$this->htmlOptions['title'] = CHtml::encode($this->descr);
}
}
$name = $this->getName();
if ($this->getValue() == '') {
$this->setValue(CHtml::encode($this->default));
}
$value = $this->getValue();
$htmlOptions = array();
if (isset($this->htmlOptions)) {
$htmlOptions += $this->htmlOptions;
}
if (isset($this->field->htmlOptions)) {
$htmlOptions += $this->field->htmlOptions;
}
// clear empty attributes
//
if (isset($htmlOptions)) {
foreach ($htmlOptions as $opt => $val) {
if (empty($val)) {
unset($htmlOptions[$opt]);
}
}
}
//
// IMPORTANT:
// every input field must have 'alt' signature stablished to 'input' or it wont be recognized
// by eyuiform.js when post.
if (!isset($htmlOptions['alt'])) {
$htmlOptions['alt'] = 'input';
}
$inputName = $this->modelName . "[" . $name . "]";
$htmlOptions['id'] = $this->getName();
$req = $this->required == true ? '*' : '';
$reqClass = $this->required == true ? 'required' : '';
if ($this->field->uicomponent == 'textbox') {
$input = CHtml::textField($inputName, $value, $htmlOptions);
}
if ($this->field->uicomponent == 'textarea') {
$input = CHtml::textArea($inputName, $value, $htmlOptions);
}
if ($this->field->uicomponent == 'listbox') {
$input = CHtml::listBox($inputName, $value, $this->checkOptions($this->field->options), $htmlOptions);
}
if ($this->field->uicomponent == 'combobox') {
$prompt = array();
if ($this->field->prompt != null) {
$prompt = $this->field->prompt;
}
$input = CHtml::dropDownList($inputName, $value, $prompt + $this->checkOptions($this->field->options), $htmlOptions);
}
if ($this->field->uicomponent == 'checkbox') {
if (!isset($htmlOptions['class'])) {
$htmlOptions['class'] = 'checkbox';
}
$input = CHtml::checkBox($inputName, $this->getValue() > 0, $htmlOptions);
}
if ($this->field->uicomponent == 'datebox') {
$id = $this->getName();
$language = Yii::app()->language;
$dp_options = CJavaScript::encode(array('constrainInput' => true, 'dateFormat' => $this->dateformat, 'showOn' => "both", 'showButtonPanel' => true, 'changeMonth' => true, 'changeYear' => true));
if ($language == 'en' || $language == "" || $language == 'en-US' || $language == 'en_us') {
$language = 'en-GB';
}
$js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$language}'], {$dp_options}));";
$input = CHtml::textField($inputName, $value, $htmlOptions);
Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id, $js);
}
if ($this->field->uicomponent == 'checkboxlist') {
/*
$input = "<div class='checkboxes'>";
foreach($this->field->options as $_key=>$_val){
$_id = $this->id."_".$_key;
$input .= "<span class='checkbox'><label for='{$_id}'>{$_val}</label>".CHtml::checkBox(
$name,false,array('id'=>$_id))."</span>";
}
$input .= "</div>";
*/
}
//.........这里部分代码省略.........
示例4: run
/**
* Render widget input.
*/
public function run()
{
if (isset($this->options['ajax'])) {
if ($this->hasModel()) {
echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
} else {
echo CHtml::textField($this->name, $this->value, $this->htmlOptions);
}
} else {
if (isset($this->htmlOptions['multiple']) && $this->htmlOptions['multiple'] == 'true') {
if ($this->hasModel()) {
echo CHtml::activeListBox($this->model, $this->attribute, $this->data, $this->htmlOptions);
} else {
echo CHtml::listBox($this->model, $this->attribute, $this->data, $this->htmlOptions);
}
} else {
if ($this->hasModel()) {
echo CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
} else {
echo CHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions);
}
}
}
}
示例5: eT
<br />
</fieldset>
<fieldset class='popupgroup'>
<legend>
<?php
eT("Survey");
?>
</legend>
<p>
<?php
if (!empty($tokensurveynames)) {
//$option[''] = gT("Select...");
foreach ($tokensurveynames as $row) {
$option[$row['surveyls_survey_id']] = $row['surveyls_title'];
}
echo CHtml::listBox('survey_id', 'id="survey_id"', $option, array('style' => 'width: 400px; border: 0px; cursor: pointer', 'size' => 10));
}
?>
</p><br />
</fieldset>
<fieldset class='popupgroup'>
<legend>
<?php
eT("Options");
?>
</legend>
<?php
$data = array('id' => 'redirect', 'value' => 'TRUE', 'style' => 'margin:10px');
echo CHtml::checkBox('redirect', TRUE, $data);
?>
<label for='redirect'><?php
示例6: eT
<div class="col-sm-10">
<?php
echo CHtml::checkBox('filterduplicatetoken', true);
?>
</div>
</div>
<!-- Duplicates are determined by -->
<div class="form-group" id='lifilterduplicatefields'>
<label class="col-sm-2 control-label" for='filterduplicatefields'><?php
eT("Duplicates are determined by:");
?>
</label>
<div class="col-sm-10">
<?php
echo CHtml::listBox('filterduplicatefields', array('firstname', 'lastname', 'email'), $aTokenTableFields, array('multiple' => 'multiple', 'size' => '7'));
?>
</div>
</div>
<!-- Buttons -->
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<?php
echo CHtml::htmlButton(gT("Upload"), array('type' => 'submit', 'name' => 'upload', 'value' => 'import', 'class' => 'btn btn-default'));
?>
</div>
</div>
</form>
<!-- Infos -->
示例7: eT
</div>
<div class="col-lg-2" style="overflow-x: hidden">
<div>
<?php
eT("Other files:");
?>
<br/>
<?php
// TODO printf(gT("(path for css: %s)"), $filespath)
?>
<?php
echo CHtml::form(array('admin/templates/sa/templatefiledelete'), 'post');
echo CHtml::listBox('otherfile', '', array_combine($otherfiles, $otherfiles), array('size' => 11, 'class' => "form-control"));
?>
<br>
<?php
if (Permission::model()->hasGlobalPermission('templates', 'delete')) {
?>
<input type='submit' class='btn btn-default' value='<?php
eT("Delete");
?>
' onclick="javascript:return confirm('<?php
eT("Are you sure you want to delete this file?", "js");
?>
')"/>
<?php
}
示例8: isset
</div>
<div class="grid-9-12">
<?php
echo CHtml::listBox('tasks', isset($_POST['tasks']) ? $_POST['tasks'] : isset($items_selected[CAuthItem::TYPE_TASK]) ? $items_selected[CAuthItem::TYPE_TASK] : '', $items[CAuthItem::TYPE_TASK], array('size' => 20, 'multiple' => 'multiple'));
?>
</div>
<div class="clear"></div>
<hr />
<div class="grid-3-12"><?php
echo CHtml::label(at('Additional Operations'), 'operations');
?>
</div>
<div class="grid-9-12">
<?php
echo CHtml::listBox('operations', isset($_POST['operations']) ? $_POST['operations'] : isset($items_selected[CAuthItem::TYPE_OPERATION]) ? $items_selected[CAuthItem::TYPE_OPERATION] : '', $items[CAuthItem::TYPE_OPERATION], array('size' => 20, 'multiple' => 'multiple'));
?>
</div>
<div class="clear"></div>
<hr />
</div>
<div id="tabs-5">
<div class="grid-6-12">
<?php
echo at('Type in the zipcode and fill in the billing information if the information exists in our databases.');
?>
<div class="clear"></div>
<div class="grid-6-12">
示例9: eT
<br />
</fieldset>
<fieldset class='popupgroup'>
<legend>
<?php
eT("Survey");
?>
</legend>
<p>
<?php
if (!empty($tokensurveynames)) {
//$option[''] = gT("Select...");
foreach ($tokensurveynames as $row) {
$option[$row['surveyls_survey_id']] = $row['surveyls_title'];
}
echo CHtml::listBox('survey_id', 'id="survey_id"', $option, array('class' => 'form-control', 'size' => 8));
}
?>
</p><br />
</fieldset>
<fieldset class='popupgroup'>
<legend>
<?php
eT("Options");
?>
</legend>
<div class='form-group'>
<label class='control-label col-sm-8' for='redirect'><?php
eT("Display survey participants after adding?");
?>
</label>
示例10: run
public function run()
{
echo "<table style=\"width:100%;\" border=\"1\">";
echo "<tr>";
echo "<td style=\"text-align:center;\">";
if (isset($this->leftTitle)) {
echo CHtml::label($this->leftTitle, "leftTitle");
}
$this->LeftListHtmlOptions = array_merge($this->LeftListHtmlOptions, array('id' => 'select_left', 'multiple' => 'multiple'));
echo CHtml::listBox($this->listName . "1[]", '', $this->LeftDataList, $this->LeftListHtmlOptions);
echo "</td>";
echo "<td style=\"text-align:center;\">";
echo CHtml::button('<', array('id' => 'options_left')) . "<br /><br />";
echo CHtml::button('>', array('id' => 'options_right')) . "<br /><br />";
echo CHtml::button('<<', array('id' => 'options_left_all')) . "<br /><br />";
echo CHtml::button('>>', array('id' => 'options_right_all')) . "<br /><br />";
echo "</td>";
echo "<td style=\"text-align:center;\">";
if (isset($this->rightTitle)) {
echo CHtml::label($this->rightTitle, "rightTitle");
}
$this->RightListHtmlOptions = array_merge($this->RightListHtmlOptions, array('id' => 'select_right', 'multiple' => 'multiple'));
echo CHtml::listBox($this->listName . "2[]", '', $this->RightDataList, $this->RightListHtmlOptions);
echo "</td>";
echo "</tr>";
echo "</table>";
$this->registerClientScript();
Yii::app()->clientScript->registerScript('jQueryOptionTransfer', '
$(function() {
$("#select_left").multiSelect("#select_right", {trigger:"#options_right"});
$("#select_right").multiSelect("#select_left", {trigger:"#options_left"});
$("#select_left").multiSelect("#select_right", {allTrigger:"#options_right_all"});
$("#select_right").multiSelect("#select_left", {allTrigger:"#options_left_all"});
});
');
parent::init();
}
示例11: array
$.fn.yiiGridView.update("menu-grid");
}
});
return false; }')), 'template' => '{up}{down}{update}{delete}', 'header' => CHtml::dropDownList('pageSize', $pageSize, array(5 => 5, 20 => 20, 50 => 50, 100 => 100), array('class' => 'change-pagesize'))))));
Yii::app()->clientScript->registerScript('initPageSize', <<<EOD
\$('.change-pagesize').live('change', function() {
\$.fn.yiiGridView.update('menu-grid',{ data:{ pageSize: \$(this).val() }})
});
EOD
, CClientScript::POS_READY);
?>
<?php
echo CHtml::beginForm();
echo CHtml::hiddenField('tree', 'manage');
echo CHtml::listBox('node', '1', $data, array('size' => '10'));
?>
<br /><br />
<?php
echo CHtml::textField('name');
echo CHtml::submitButton('Добавить пункт', array('name' => 'add'));
?>
<br /><br />
<br /><br />
<?php
echo CHtml::dropDownList('nodeto', '1', $data);
?>
<br />
<?php
示例12: array
if (in_array($value->matrix_param->alias, array('role'))) {
?>
<?php
echo CHtml::listBox('MatrixTypeActionParamValue[' . $value->matrix_param->id . '][]', array(), $roles, array('size' => 0));
?>
<?php
} elseif (in_array($value->matrix_param->alias, array('matrix_type'))) {
?>
<?php
echo CHtml::listBox('MatrixTypeActionParamValue[' . $value->matrix_param->id . '][]', array(), $matrixtypes, array('size' => 0));
?>
<?php
} elseif (in_array($value->matrix_param->alias, array('spec_alias_bonus_in', 'spec_alias_money_out'))) {
?>
<?php
echo CHtml::listBox('MatrixTypeActionParamValue[' . $value->matrix_param->id . '][]', array(), $specalias, array('size' => 0));
?>
<?php
} else {
?>
<?php
echo CHtml::textField('MatrixTypeActionParamValue[' . $value->matrix_param->id . '][]');
?>
<?php
}
?>
</td>
<td></td>
<td></td>
</tr>
<?php
示例13: getSettingForm
/**
* Parse each setting
*/
public function getSettingForm($setting)
{
$setting = $this->parseSetting($setting);
$name = 'setting_' . $setting->id;
$value = $setting->value !== null ? $setting->value : $setting->default_value;
switch ($setting->type) {
case 'textarea':
echo CHtml::textArea($name, $value, array('rows' => 5, 'class' => 'textbox', 'disabled' => $setting->disabled ? 'disabled' : ''));
break;
case 'dropdown':
echo CHtml::dropDownList($name, $value, $this->convertExtraToArray($setting->extra), array('class' => 'chzn-select', 'disabled' => $setting->disabled ? 'disabled' : ''));
break;
case 'multi':
echo CHtml::listBox($name, $value ? explode(',', $value) : '', $this->convertExtraToArray($setting->extra), array('size' => 20, 'multiple' => 'multiple', 'class' => 'chosen', 'disabled' => $setting->disabled ? 'disabled' : ''));
break;
case 'checkbox':
echo CHtml::checkbox($name, $setting->value != '' ? $setting->value : $setting->default_value, array('class' => '', 'disabled' => $setting->disabled ? 'disabled' : ''));
break;
case 'yesno':
echo CHtml::dropDownList($name, $value, array('0' => Yii::t('global', 'No'), '1' => Yii::t('global', 'Yes')), array('class' => 'chzn-select', 'disabled' => $setting->disabled ? 'disabled' : ''));
break;
case 'editor':
Yii::app()->customEditor->getEditor(array('name' => $name, 'value' => $value));
break;
case 'text':
default:
echo CHtml::textField($name, $value, array('class' => 'textbox', 'disabled' => $setting->disabled ? 'disabled' : ''));
break;
}
}
示例14: listBox
/**
* Generates a list box.
* @param string $name the input name
* @param mixed $select the selected value(s). This can be either a string for single selection or an array for multiple selections.
* @param array $data data for generating the list options (value=>display)
* You may use {@link listData} to generate this data.
* Please refer to {@link listOptions} on how this data is used to generate the list options.
* Note, the values and labels will be automatically HTML-encoded by this method.
* @param array $htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special
* attributes are also recognized. See {@link clientChange} and {@link tag} for more details.
* In addition, the following options are also supported specifically for list box:
* <ul>
* <li>encode: boolean, specifies whether to encode the values. Defaults to true.</li>
* <li>prompt: string, specifies the prompt text shown as the first list option. Its value is empty. Note, the prompt text will NOT be HTML-encoded.</li>
* <li>empty: string, specifies the text corresponding to empty selection. Its value is empty.
* The 'empty' option can also be an array of value-label pairs.
* Each pair will be used to render a list option at the beginning. Note, the text label will NOT be HTML-encoded.</li>
* <li>options: array, specifies additional attributes for each OPTION tag.
* The array keys must be the option values, and the array values are the extra
* OPTION tag attributes in the name-value pairs. For example,
* <pre>
* array(
* 'value1'=>array('disabled'=>true, 'label'=>'value 1'),
* 'value2'=>array('label'=>'value 2'),
* );
* </pre>
* </li>
* </ul>
* @return string the generated list box
* @see clientChange
* @see inputField
* @see listData
*/
public static function listBox($name, $select, $data, $htmlOptions = array())
{
$help = self::getHelp($htmlOptions);
ob_start();
echo CHtml::listBox($name, $select, $data, $htmlOptions);
echo $help;
return ob_get_clean();
}
示例15: array
</div>
<div id="fieldTypeStat_<?php
echo $field->id;
?>
">
<?php
echo $field->getCurrentFilltype();
?>
</div>
<div id="fieldTypeDyn_<?php
echo $field->id;
?>
" style="display: none;">
<?php
echo CHtml::listBox('Fields[is_user_filltype]', $field->is_user_filltype || $field->filltype == NULL ? (int) FALSE : $field->filltype->type, Fields::getFilltypesArray($field->field), array('id' => 'fieldTypeText_' . $field->id, 'size' => 1, 'onChange' => 'getFieldListForDuplicate(' . $field->id . ', this)'));
?>
<span id="fieldCopy_<?php
echo $field->id;
?>
" style="display: none;"></span>
<div style="float: right; width: 60px; margin-top: 5px;">
<?php
echo CHtml::link('<span class="apply" title="Сохранить тип"> </span>', 'javascript: void(0)', array('onClick' => 'saveFieldType(' . $field->id . ')'));
?>
<?php
echo CHtml::link('<span class="cancel" title="Отмена"> </span>', 'javascript: void(0)', array('onClick' => 'hideFieldType(' . $field->id . ')'));
?>
</div>
</div>