How Create Dropdownlist Disabled="disabled"

Good afternoon.

Be kind tell me how to pull through dropDownList elements from the database, while the elements that where the value of active = no appear in the list but you could not choose.

Now I do so.

<?php echo $form->dropDownList(

$model,'user', CHtml::listData(Driver::model()->findAll(),'id', 'last_name'),

array('prompt'=>'Select a driver:','options'=>array('3'=>array('disabled'=>'disabled')))); ?>

But this is not exactly what I need to get.

Now it turns out if ID (from the base) = 3, then the list item disabled. How to make that reconciliation was conducted with the active field which has 2 values ​​yes / no.

Ideally, I need to get a drop-down list that’s like this:

example on jsfiddle

First displays the available items in the list , then those who are not active.

Thank you.

Ideally, I need to get a drop-down list that’s like this: / simbioziz / dbh2D / 1 / - example on jsfiddle

See below links:

I think maybe you can use ‘active’ as group field.

<?php echo $form->dropDownList(

$model,'user', CHtml::listData(Driver::model()->findAll(),'id', 'last_name', 'active'),

array('prompt'=>'Select a driver:'))); ?>

This option does not suit me.

Need to display all users, but you could only choose available.

I made ​​an example - /simbioziz/dbh2D/2/

Well you don’t have to use the CHtml to generate the select options, you can always write vanilla html

<select name="driver">

<?php foreach (Driver::model()->findAll() as $driver): ?>

	<!-- The array contains all the disable driver options -->

	<?php if (in_array($driver->id, array(3, 2))): ?>

		<option disabled><?php echo $driver->name; ?></option>

	<?php else: ?>

		<option value="<?php echo $driver->id; ?>"><?php echo $driver->name; ?></option>

	<?php endif ?>

<?php endforeach ?>