Posts Tagged with dropdownlist

Displaying 1-7 of 7 results.
Resolved: Yii 1.1 CHtml activeDropDownList htmlOptions
posted by admin on November 8, 2016
I have , and want to add htmlOPtions array, for example style, or class etc...

CHtml::activeDropDownList($model, 'status_id', array_combine(array_values(array("", "3", "1")), array("Все", "Заявки", "В ожидании")));
Read more
Resolved: Yii 1.1 Cgridview filter listdata without findAll from db, with php array
posted by admin on November 7, 2016
I have CGridView with select filter, and I want to insert select box info manually with php array.
Now I have result with findAll():

<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'application-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
...
array(
'name'=>'status_id',
'value'=>'$data->status->name',
'type'=>'html',
'filter' => CHtml::listData(Status::model()->findAll(), 'id', 'name'),
),
...
),
)
);
Read more
Resolved: Yii 1.1 listdata multiple fields
posted by admin on October 25, 2016
I have form with select box, and want to generate options with multiple columns.
Now:

$criteria = new CDbCriteria();
...//if you have criteria condition
$type_list=CHtml::listData(Paper::model()->findAll($criteria),'id','title'); ?>
<?php echo $form->dropDownList($model, 'paper_id', array(''=>Yii::t('t', 'Выберите бумагу'))+$type_list, array('options' => array($model->paper_id=>array('selected'=>true)))); ?>

In output i see:
  • Title 1
  • Title 2
  • etc...
  • Title N


But I want multiple columns, and want to see output like this:
  • Title 1, field 1, another field 1, etc...
  • Title 2, field 2, another field 2, etc...
  • ...
  • Title N, field N, another field N, etc...
Read more
Resolved: Submit form on change of dropdown list
posted by admin on April 26, 2016
I have SELECT dropdown list

<form method="GET" >
<select id="id_period" name="period">
<option value="day">day</option>
<option value="week">week</option>
<option value="month">month</option>
<option value="all" selected="selected">all time</option>
</select>
</form>

I want to submit form on changeRead more
Wiki: Yii 1.1 cgridview filter dropdown with relation table datawiki
posted by admin on April 7, 2016
View: admin.php

<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'media-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'caption',
'created',
'updated',
array( 'name' => 'visibility_id',
'value' => '$data->visibility_id',
'filter' => CHtml::listData(Visibility::model()->findall(), 'id', 'name'),
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>


Model: Visibility.php

class Visibility extends CActiveRecord
{
public function tableName()
{
return 'tbl_visibility';
}

public function rules()
{
return array(
//your rules here
);
}

public function relations()
{
return array(
'media' => array(self::HAS_MANY, 'Media', 'visibility_id'),
);
}

public static function model($className=__CLASS__)
{
return parent::model($className);
}
}


Model: Media.php

class Media extends CActiveRecord
{
public function tableName()
{
return 'tbl_media';
}
public function rules()
{
return array(
//your rules
//...

);
}
public function relations()
{
return array(
'visibility' => array(self::BELONGS_TO, 'Visibility', 'visibility_id'),
);
}

public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
Read more
Resolved: Yii Dropdown List Empty Value as Default
posted by admin on April 7, 2016

<?php $type_list=CHtml::listData($galleries,'id','name'); ?>
<?php echo $form->dropDownList($model, 'gallery_id', $type_list); ?>


I want to add empty option to SELECT
In output, I want to get

<select name="sel" id="sel">
<option value="0">Choose Gallery</option>
...
</selected>
Read more
Resolved: Yii form dropDownList create and update support example with empty first option
posted by admin on January 22, 2016
I have form on yii. It is news form. I want to change news category by select box and in update form have selected option.Read more