本文整理汇总了PHP中Dropdowns类的典型用法代码示例。如果您正苦于以下问题:PHP Dropdowns类的具体用法?PHP Dropdowns怎么用?PHP Dropdowns使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dropdowns类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDownAfterClass
public static function tearDownAfterClass()
{
$leadSourceDropdown = Dropdowns::model()->findByPk(103);
$leadSourceDropdown->multi = 0;
$leadSourceDropdown->save();
return parent::tearDownAfterClass();
}
示例2: quickNoteSelector
public function quickNoteSelector(CFormModel $formModel)
{
ob_start();
ob_implicit_flush(false);
echo CHtml::label(Yii::t('app', 'Quick Note'), 'quickNote', array('style' => 'display:inline-block; margin-right: 10px;'));
echo X2Html::dropDownList('quickNote', '', array_merge(array('' => '-'), Dropdowns::getItems(117)), array('ajax' => array('type' => 'GET', 'url' => Yii::app()->controller->createUrl('/site/dynamicDropdown'), 'data' => 'js:{"val":$(this).val(),"dropdownId":"117"}', 'update' => $this->resolveIds('#quickNote2')), 'id' => $this->resolveId('quickNote'), 'class' => 'quick-note'));
echo X2Html::dropDownList('quickNote2', '', array('' => '-'), array('id' => $this->resolveId('quickNote2'), 'class' => 'quick-note'));
Yii::app()->clientScript->registerScript('quickNoteSelector', "\n \$('#{$this->resolveId('quickNote2')}').change (function () {\n \$(this).next ().val (\$(this).val ());\n });\n ");
return ob_get_clean();
}
示例3: statusList
public static function statusList()
{
$field = Fields::model()->findByAttributes(array('modelName' => 'Quotes', 'fieldName' => 'status'));
$dropdown = Dropdowns::model()->findByPk($field->linkType);
return json_decode($dropdown->options);
/*
return array(
'Draft'=>Yii::t('quotes','Draft'),
'Presented'=>Yii::t('quotes','Presented'),
"Issued"=>Yii::t('quotes','Issued'),
"Won"=>Yii::t('quotes','Won')
); */
}
示例4: listOption
public static function listOption($attributes, $name)
{
if ($attributes instanceof Fields) {
$attributes = $attributes->getAttributes();
}
$data = array('name' => $name, 'label' => $attributes['attributeLabel']);
if (isset($attributes['type']) && $attributes['type']) {
$data['type'] = $attributes['type'];
}
if (isset($attributes['required']) && $attributes['required']) {
$data['required'] = 1;
}
if (isset($attributes['readOnly']) && $attributes['readOnly']) {
$data['readOnly'] = 1;
}
if (isset($attributes['type'])) {
if ($attributes['type'] === 'assignment' || $attributes['type'] === 'optionalAssignment') {
$data['options'] = AuxLib::dropdownForJson(X2Model::getAssignmentOptions(true, true));
} elseif ($attributes['type'] === 'dropdown' && isset($attributes['linkType'])) {
$data['linkType'] = $attributes['linkType'];
$data['options'] = AuxLib::dropdownForJson(Dropdowns::getItems($attributes['linkType']));
} elseif ($attributes['type'] === 'link' && isset($attributes['linkType'])) {
$staticLinkModel = X2Model::model($attributes['linkType']);
if (array_key_exists('X2LinkableBehavior', $staticLinkModel->behaviors())) {
$data['linkType'] = $attributes['linkType'];
$data['linkSource'] = Yii::app()->controller->createUrl($staticLinkModel->autoCompleteSource);
}
}
}
return $data;
}
示例5: Dropdowns
$fax = $current_row->fax;
$email = $current_row->email;
$organization = $current_row->organization;
$receive_newsletter = $current_row->receive_newsletter;
if ($receive_newsletter == 1) {
$receive_newsletter = "checked='checked'";
}
}
}
/**
* Dropdowns object.
*
* Intialize object from Dropdowns class which contains methods fill all dropdowns of website.
* @var object.
*/
$dropdowns = new Dropdowns();
/**
* Country object.
*
* Intialize object from Country controller class.
* @var object.
*/
$this->load->controller(ADMIN . '/Country');
$country_object = new Country();
/**
* Member controller object.
*
* Intialize object from Member controller class.
* @var object.
*/
$this_object = new Member();
示例6: getViewFileParams
/**
* Send the chart type to the widget content view
*/
public function getViewFileParams()
{
if (!isset($this->_viewFileParams)) {
$this->_viewFileParams = array_merge(parent::getViewFileParams(), array('chartType' => $this->chartType, 'chartSettingsDataProvider' => self::getChartSettingsProvider($this->chartType), 'eventTypes' => array('all' => Yii::t('app', 'All Events')) + Events::$eventLabels, 'socialSubtypes' => json_decode(Dropdowns::model()->findByPk(113)->options, true), 'visibilityFilters' => array('1' => 'Public', '0' => 'Private'), 'suppressChartSettings' => false, 'chartType' => 'usersChart', 'widgetUID' => $this->widgetUID, 'metricTypes' => User::getUserOptions()));
}
return $this->_viewFileParams;
}
示例7: array_keys
?>
' value='' />-->
<textarea type='text' name='name' id='feed-post-editor'
placeholder='<?php
echo Yii::t('app', 'Enter text here...');
?>
'></textarea>
<fieldset data-role='controlgroup' data-type='horizontal'>
<?php
$userIds = array_keys($users);
$firstUser = $userIds[0];
echo CHtml::dropDownList('associationId', $firstUser, $users, array('data-mini' => 'true', 'id' => 'feed-post-association-id'));
echo CHtml::dropDownList('visibility', 1, array(1 => Yii::t('actions', 'Public'), 0 => Yii::t('actions', 'Private')), array('data-mini' => 'true', 'id' => 'feed-post-visibility'));
echo CHtml::dropDownList('subtype', 1, array_map(function ($item) {
return Yii::t('app', $item);
}, Dropdowns::getSocialSubtypes()), array('data-mini' => 'true', 'id' => 'feed-post-subtype'));
?>
</fieldset>
<button type='submit' class='x2-button' id='feed-post-button'
data-inline='true'><?php
echo Yii::t('app', 'Submit Post');
?>
</button>
<?php
echo X2Html::csrfToken();
?>
</form>
<div id="attachments" style='display: none;'>
<?php
$this->widget('Attachments', array('associationType' => 'feed', 'associationId' => Yii::app()->user->getId(), 'mobile' => true));
?>
示例8: getDropdownIndex
/**
* Returns dropdown value(s) for given key(s)
* @return array|string
*/
public function getDropdownIndex($id, $key)
{
$arr = Dropdowns::getItems($id);
if (is_array($key)) {
return array_map(function ($value) use($arr) {
$index = array_search($value, $arr);
if ($index === false) {
return $value;
} else {
return $index;
}
}, $key);
} else {
if (array_search($key, $arr) !== false) {
return array_search($key, $arr);
} else {
return $key;
}
}
}
示例9: renderFilterCellContent
public function renderFilterCellContent()
{
switch ($this->fieldType) {
case 'boolean':
echo CHtml::activeDropdownList($this->grid->filter, $this->name, array('' => '- ' . Yii::t('app', 'Select') . ' -', '1' => Yii::t('app', 'Yes'), 'false' => Yii::t('app', "No")), array('class' => 'x2-minimal-select-filtercol'));
break;
case 'dropdown':
$dropdown = Dropdowns::model()->findByPk($this->fieldModel['linkType']);
if ($dropdown instanceof Dropdowns) {
$options = json_decode($dropdown->options, 1);
if (!$dropdown->multi) {
$defaultOption = array('' => '- ' . Yii::t('app', 'Select') . ' -');
$options = is_array($options) ? array_merge($defaultOption, $options) : $defaultOption;
}
//$selected = isset($options[$this->grid->filter->{$this->name}]) ?
//$this->grid->filter->{$this->name} : '';
echo CHtml::activeDropdownList($this->grid->filter, $this->name, $options, array('class' => 'x2-minimal-select-filtercol' . ($dropdown->multi ? ' x2-multiselect-dropdown x2-datacolumn-multiselect' : ''), 'multiple' => $dropdown->multi ? 'multiple' : '', 'data-selected-text' => $dropdown->multi ? 'option(s)' : ''));
} else {
parent::renderFilterCellContent();
}
break;
case 'visibility':
echo CHtml::activeDropDownList($this->grid->filter, $this->name, array('' => '- ' . Yii::t('app', 'Select') . ' -', 1 => Yii::t('app', 'Public'), 0 => Yii::t('app', 'Private'), 2 => Yii::t('app', 'User\'s Groups')), array('class' => 'x2-minimal-select-filtercol'));
break;
case 'dateTime':
case 'date':
Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
$that = $this;
$renderWidget = function () use($that) {
echo Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $that->grid->filter, 'attribute' => $that->name, 'mode' => 'date', 'options' => array('dateFormat' => Formatter::formatDatePicker('medium')), 'htmlOptions' => array('id' => 'datePicker' . $that->name, 'class' => 'datePicker x2-gridview-filter-datepicker'), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true);
};
if ($this->grid->ajax) {
X2Widget::ajaxRender($renderWidget);
} else {
$renderWidget();
}
break;
default:
parent::renderFilterCellContent();
}
}
示例10: getDropdownOptions
public function getDropdownOptions()
{
if ($this->linkType instanceof X2StaticDropdown) {
return array('options' => $this->linkType->options, 'multi' => false);
} else {
return Dropdowns::getItems($this->linkType, null, true);
}
}
示例11: renderModelInput
public static function renderModelInput(CModel $model, Fields $field, $htmlOptions = array())
{
if ($field->required) {
if (isset($htmlOptions['class'])) {
$htmlOptions['class'] .= ' x2-required';
} else {
$htmlOptions = array_merge(array('class' => 'x2-required'), $htmlOptions);
}
}
$fieldName = $field->fieldName;
if (!isset($field)) {
return null;
}
switch ($field->type) {
case 'text':
return CHtml::activeTextArea($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), $htmlOptions));
// array(
// 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null,
// 'disabled'=>$item['readOnly']? 'disabled' : null,
// 'title'=>$field->attributeLabel,
// 'style'=>$default?'color:#aaa;':null,
// ));
// array(
// 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null,
// 'disabled'=>$item['readOnly']? 'disabled' : null,
// 'title'=>$field->attributeLabel,
// 'style'=>$default?'color:#aaa;':null,
// ));
case 'date':
$oldDateVal = $model->{$fieldName};
$model->{$fieldName} = Formatter::formatDate($model->{$fieldName}, 'medium');
Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
$input = Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $fieldName, 'mode' => 'date', 'options' => array('dateFormat' => Formatter::formatDatePicker(), 'changeMonth' => true, 'changeYear' => true), 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true);
$model->{$fieldName} = $oldDateVal;
return $input;
case 'dateTime':
$oldDateTimeVal = $model->{$fieldName};
$model->{$fieldName} = Formatter::formatDateTime($model->{$fieldName});
Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
$input = Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $fieldName, 'mode' => 'datetime', 'options' => array('dateFormat' => Formatter::formatDatePicker('medium'), 'timeFormat' => Formatter::formatTimePicker(), 'ampm' => Formatter::formatAMPM(), 'changeMonth' => true, 'changeYear' => true), 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true);
$model->{$fieldName} = $oldDateTimeVal;
return $input;
case 'dropdown':
// Note: if desired to translate dropdown options, change the seecond argument to
// $model->module
$om = Dropdowns::getItems($field->linkType, null, true);
$multi = (bool) $om['multi'];
$dropdowns = $om['options'];
$curVal = $multi ? CJSON::decode($model->{$field->fieldName}) : $model->{$field->fieldName};
$dependencyCount = X2Model::model('Dropdowns')->countByAttributes(array('parent' => $field->linkType));
$fieldDependencyCount = X2Model::model('Fields')->countByAttributes(array('modelName' => $field->modelName, 'type' => 'dependentDropdown', 'linkType' => $field->linkType));
if ($dependencyCount > 0 && $fieldDependencyCount > 0) {
$ajaxArray = array('ajax' => array('type' => 'GET', 'url' => Yii::app()->controller->createUrl('/site/dynamicDropdown'), 'data' => 'js:{"val":$(this).val(),"dropdownId":"' . $field->linkType . '", "field":true, "module":"' . $field->modelName . '"}', 'success' => 'function(data){
if(data){
data=JSON.parse(data);
if(data[0] && data[1]){
$("#' . $field->modelName . '_"+data[0]).html(data[1]);
}
}
}'));
} else {
$ajaxArray = array();
}
$htmlOptions = array_merge($htmlOptions, $ajaxArray, array('title' => $field->attributeLabel));
if ($multi) {
$multiSelectOptions = array();
if (!is_array($curVal)) {
$curVal = array();
}
foreach ($curVal as $option) {
$multiSelectOptions[$option] = array('selected' => 'selected');
}
$htmlOptions = array_merge($htmlOptions, array('options' => $multiSelectOptions, 'multiple' => 'multiple'));
} else {
$htmlOptions = array_merge($htmlOptions, array('empty' => Yii::t('app', "Select an option")));
}
return CHtml::activeDropDownList($model, $field->fieldName, $dropdowns, $htmlOptions);
case 'dependentDropdown':
return CHtml::activeDropDownList($model, $field->fieldName, array('' => '-'), array_merge(array('title' => $field->attributeLabel), $htmlOptions));
case 'link':
$linkSource = null;
$linkId = '';
$name = '';
if (class_exists($field->linkType)) {
// Create a model for autocompletion:
if (!empty($model->{$fieldName})) {
list($name, $linkId) = Fields::nameAndId($model->{$fieldName});
$linkModel = self::getLinkedModelMock($field->linkType, $name, $linkId, true);
} else {
$linkModel = X2Model::model($field->linkType);
}
if ($linkModel instanceof X2Model && $linkModel->asa('X2LinkableBehavior') instanceof X2LinkableBehavior) {
$linkSource = Yii::app()->controller->createUrl($linkModel->autoCompleteSource);
$linkId = $linkModel->id;
$oldLinkFieldVal = $model->{$fieldName};
$model->{$fieldName} = $name;
}
}
$input = CHtml::hiddenField($field->modelName . '[' . $fieldName . '_id]', $linkId, array('id' => $field->modelName . '_' . $fieldName . "_id")) . Yii::app()->controller->widget('zii.widgets.jui.CJuiAutoComplete', array('model' => $model, 'attribute' => $fieldName, 'source' => $linkSource, 'value' => $name, 'options' => array('minLength' => '1', 'select' => 'js:function( event, ui ) {
$("#' . $field->modelName . '_' . $fieldName . '_id").val(ui.item.id);
//.........这里部分代码省略.........
示例12: array
}
$fieldTypes = Fields::getFieldTypes('title');
echo $form->dropDownList($model, 'type', ArrayUtil::asorti($fieldTypes), array('id' => 'fieldType', 'class' => $new ? 'new' : 'existing'));
?>
<?php
echo $form->error($model, 'type');
?>
</div>
<div class="row">
<?php
// Render a dropdown menu and any other fields
// for the "linkType" field
$genericLabel = CHtml::label(Yii::t('app', 'Type'), CHtml::resolveName($model, $assignTypeName));
switch ($model->type) {
case "dropdown":
$dropdowns = Dropdowns::model()->findAll();
$arr = array();
foreach ($dropdowns as $dropdown) {
$arr[$dropdown->id] = $dropdown->name;
}
echo CHtml::activeDropDownList($model, 'linkType', $arr, array('id' => 'dropdown-type', 'class' => $new ? 'new' : 'existing'));
break;
case "assignment":
$assignTypeName = 'linkType';
echo $genericLabel;
echo CHtml::activeDropDownList($model, 'linkType', array(NULL => Yii::t('app', 'Single'), 'multiple' => Yii::t('app', 'Multiple')), array('id' => 'assignment-multiplicity', 'class' => $new ? 'new' : 'existing'));
break;
case "link":
$linkTypes = Fields::getLinkTypes();
$options = array();
foreach ($linkTypes as $type) {
示例13: array
echo '<div class="formInputBox" style="width:' . $item['width'] . 'px;height:' . $item['height'] . ';">';
$default = $model->{$fieldName} == $field->attributeLabel;
if ($field->type == 'varchar' || $field->type == 'email' || $field->type == 'url' || $field->type == 'int' || $field->type == 'float' || $field->type == 'currency') {
echo $form->textField($model, $field->fieldName, array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel, 'style' => $default ? 'color:#aaa;' : null));
} else {
if ($field->type == 'text') {
echo $form->textArea($model, $field->fieldName, array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel, 'style' => $default ? 'color:#aaa;' : null));
} else {
if ($field->type == 'text') {
echo $form->textArea($model, $field->fieldName, array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel, 'onfocus' => $default ? 'toggleText(this);' : null, 'onblur' => $default ? 'toggleText(this);' : null, 'style' => $default ? 'color:#aaa;' : null));
} elseif ($field->type == 'date') {
$model->{$fieldName} = $this->formatDate($model->{$fieldName});
Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
$this->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $field->fieldName, 'mode' => 'date', 'options' => array('dateFormat' => $this->formatDatePicker()), 'htmlOptions' => array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => defined($item['readOnly']) && $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()));
} elseif ($field->type == 'dropdown') {
$dropdowns = Dropdowns::getItems($field->linkType);
echo $form->dropDownList($model, $field->fieldName, $dropdowns, array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel));
} elseif ($field->type == 'link') {
// if(empty($model->$fieldName))
// $model->$fieldName = '';
$linkSource = null;
$linkId = '';
if (class_exists($field->linkType)) {
// if the field is an ID, look up the actual name
if (isset($model->{$fieldName}) && ctype_digit($model->{$fieldName})) {
$linkModel = CActiveRecord::model($field->linkType)->findByPk($model->{$fieldName});
if (isset($linkModel)) {
$model->{$fieldName} = $linkModel->name;
$linkId = $linkModel->id;
} else {
$model->{$fieldName} = '';
示例14: actionGetFields
public function actionGetFields($model)
{
if (!class_exists($model)) {
echo 'false';
return;
}
$fieldModels = X2Model::model($model)->getFields();
$fields = array();
foreach ($fieldModels as &$field) {
if ($field->isVirtual) {
continue;
}
$data = array('name' => $field->fieldName, 'label' => $field->attributeLabel, 'type' => $field->type);
if ($field->required) {
$data['required'] = 1;
}
if ($field->readOnly) {
$data['readOnly'] = 1;
}
if ($field->type === 'assignment' || $field->type === 'optionalAssignment') {
$data['options'] = AuxLib::dropdownForJson(X2Model::getAssignmentOptions(true, true));
} elseif ($field->type === 'dropdown') {
$data['linkType'] = $field->linkType;
$data['options'] = AuxLib::dropdownForJson(Dropdowns::getItems($field->linkType));
}
if ($field->type === 'link') {
$staticLinkModel = X2Model::model($field->linkType);
if (array_key_exists('X2LinkableBehavior', $staticLinkModel->behaviors())) {
$data['linkType'] = $field->linkType;
$data['linkSource'] = Yii::app()->controller->createUrl($staticLinkModel->autoCompleteSource);
}
}
$fields[] = $data;
}
echo CJSON::encode($fields);
}
示例15: Social
<div class="form">
<?php
$feed = new Social();
?>
<?php
$form = $this->beginWidget('CActiveForm', array('id' => 'feed-form', 'enableAjaxValidation' => false, 'method' => 'post', 'action' => array('addPost', 'id' => Yii::app()->user->getId(), 'redirect' => 'index')));
?>
<div class="float-row">
<?php
$feed->data = Yii::t('app', 'Enter text here...');
echo $form->textArea($feed, 'data', array('style' => 'width:558px;height:50px;color:#aaa;display:block;clear:both;'));
echo $form->dropDownList($feed, 'associationId', $users);
$feed->visibility = 1;
echo $form->dropDownList($feed, 'visibility', array(1 => Yii::t('actions', 'Public'), 0 => Yii::t('actions', 'Private')));
echo $form->dropDownList($feed, 'subtype', json_decode(Dropdowns::model()->findByPk(14)->options, true));
echo CHtml::submitButton(Yii::t('app', 'Post'), array('class' => 'x2-button', 'id' => 'save-button'));
echo CHtml::button(Yii::t('app', 'Attach A File/Photo'), array('class' => 'x2-button', 'onclick' => "\$('#attachments').toggle();"));
?>
</div>
<?php
$this->endWidget();
?>
</div>
<div id="attachments" style="display:none;">
<?php
$this->widget('Attachments', array('associationType' => 'feed', 'associationId' => Yii::app()->user->getId()));
?>
</div>