activeDropDownList() public static method

Generates a drop down list for a model attribute.
public static activeDropDownList ( CModel $model, string $attribute, array $data, array $htmlOptions = [] ) : string
$model CModel the data model.
$attribute string the attribute.
$data array data for generating the list options (value=>display).
$htmlOptions array additional HTML attributes
return string the generated drop down list.
コード例 #1
0
ファイル: TbDataColumn.php プロジェクト: mfavetti/LimeSurvey
 /**
  * Renders the filter cell content. Here we can provide HTML options for actual filter input
  */
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         echo $this->filter;
     } else {
         if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false) {
             if ($this->filterInputOptions) {
                 $filterInputOptions = $this->filterInputOptions;
                 if (empty($filterInputOptions['id'])) {
                     $filterInputOptions['id'] = false;
                 }
             } else {
                 $filterInputOptions = array();
             }
             if (is_array($this->filter)) {
                 $filterInputOptions['prompt'] = '';
                 echo TbHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, $filterInputOptions);
             } else {
                 if ($this->filter === null) {
                     echo TbHtml::activeTextField($this->grid->filter, $this->name, $filterInputOptions);
                 }
             }
         } else {
             parent::renderFilterCellContent();
         }
     }
 }
コード例 #2
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     $id = $this->resolveId($id);
     echo TbHtml::openTag('div', array('class' => 'select2'));
     if ($this->hasModel()) {
         if ($this->asDropDownList) {
             echo TbHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
         } else {
             echo TbHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
         }
     } else {
         if ($this->asDropDownList) {
             echo TbHtml::dropDownList($name, $this->value, $this->data, $this->htmlOptions);
         } else {
             echo TbHtml::hiddenField($name, $this->value, $this->htmlOptions);
         }
     }
     echo '</div>';
     if ($this->assetPath !== false) {
         $this->publishAssets($this->assetPath);
         $this->registerCssFile('/select2.css');
         if ($this->registerJs) {
             $this->registerScriptFile('/select2.js', CClientScript::POS_END);
         }
     }
     if ($this->bindPlugin) {
         $options = !empty($this->pluginOptions) ? CJavaScript::encode($this->pluginOptions) : '';
         $this->getClientScript()->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').select2({$options});");
     }
 }
コード例 #3
0
 /**
  * Renders the select2 field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     if ($this->hasModel()) {
         echo $this->asDropDownList ? TbHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions) : TbHtml::activeHiddenField($this->model, $this->attribute);
     } else {
         echo $this->asDropDownList ? TbHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions) : TbHtml::hiddenField($this->name, $this->value);
     }
 }
コード例 #4
0
 public function testActiveDropDownList()
 {
     $I = $this->codeGuy;
     $html = TbHtml::activeDropDownList(new Dummy(), 'dropdown', array('1', '2', '3', '4', '5'), array('class' => 'list', 'empty' => 'Empty text', 'size' => TbHtml::INPUT_SIZE_LARGE, 'textAlign' => TbHtml::TEXT_ALIGN_CENTER));
     $select = $I->createNode($html, 'select');
     $I->seeNodeCssClass($select, 'input-large text-center list');
     $I->dontSeeNodeAttribute($select, 'size');
 }
コード例 #5
0
 /**
  * Renders a dropdown list for a model attribute.
  * @param CModel $model the data model.
  * @param string $attribute the attribute.
  * @param array $data data for generating the list options (value=>display).
  * @param array $htmlOptions additional HTML attributes.
  * @return string the generated drop down list.
  * @see TbHtml::activeDropDownList
  */
 public function dropDownList($model, $attribute, $data, $htmlOptions = array())
 {
     return TbHtml::activeDropDownList($model, $attribute, $data, $htmlOptions);
 }
コード例 #6
0
ファイル: TbActiveForm.php プロジェクト: yii-twbs/yiistrap
 /**
  * Renders a dropdown list for a model attribute.
  * This method is a wrapper of {@link CHtml::activeDropDownList}.
  * Please check {@link CHtml::activeDropDownList} for detailed information
  * about the parameters for this method.
  * @param CModel $model the data model
  * @param string $attribute the attribute
  * @param array $data data for generating the list options (value=>display)
  * @param array $htmlOptions additional HTML attributes.
  * @return string the generated drop down list
  */
 public function dropDownList($model, $attribute, $data, $htmlOptions = array())
 {
     return $this->wrapControl(TbHtml::activeDropDownList($model, $attribute, $data, $htmlOptions));
 }
コード例 #7
0
ファイル: _form.php プロジェクト: Rudianasaja/cycommerce
?>
		<?php 
echo TbHtml::error($model, 'position');
?>
		<p class="hint"><?php 
echo UserModule::t('Display order of fields.');
?>
</p>
	</div>

	<div class="row visible">
		<?php 
echo TbHtml::activeLabelEx($model, 'visible');
?>
		<?php 
echo TbHtml::activeDropDownList($model, 'visible', ProfileField::itemAlias('visible'));
?>
		<?php 
echo TbHtml::error($model, 'visible');
?>
	</div>

	<div class="row buttons">
		<?php 
echo TbHtml::button($model->isNewRecord ? UserModule::t('Create') : UserModule::t('Save'), array('color' => TbHtml::BUTTON_COLOR_SUCCESS, 'submit' => ''));
?>
	</div>

<?php 
echo TbHtml::endForm();
?>
コード例 #8
0
ファイル: _form.php プロジェクト: Rudianasaja/cycommerce
?>
		<?php 
echo $form->textField($description, 'name', array('size' => 60, 'maxlength' => 64));
?>
		<?php 
echo $form->error($description, 'name');
?>
	</div>
	
	<div class="row">
		<?php 
echo $form->labelEx($model, 'attribute_group_id');
?>
		<?php 
echo TbHtml::activeDropDownList($model, 'attribute_group_id', TbHtml::listData(AttributeGroup::model()->findAll(), 'id', function ($data) {
    return $data->getName();
}));
?>
		<?php 
echo $form->error($model, 'attribute_group_id');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'sort_order');
?>
		<?php 
echo $form->textField($model, 'sort_order');
?>
		<?php