display array in dropdownlist

Hi everyone.

I have a question.

I am trying to write an app to control an apc pdu.

For this app I have made a table users with the fields: id, name, company.

I have generated the model and the CRUD page. So now if I go to the create user page. I get 2 textfields: one for name and one for company and the create button.

The problem now is I have a login via LDAP. And I want to replace the name textfield on the create user page by a dropdownlist with all the possible LDAP users in it.

I already have the LDAP users in an array like this:

array(1) { [0]=> string(4) "User" } array(1) { [1]=> string(5) "Admin" }

How can I get both users in the dropdownlist???

I have tried this:

<?php echo $form->dropDownList($model,‘naam’,$array); ?>

But I only see Admin in the dropdownlist.

Any suggestions?????

Note: I am new to yii and relative new to php.

Hi

your array should be like

$array = array(‘0’ => ‘User’, ‘1’ => ‘Admin’);

<?php echo $form->dropDownList($model,‘naam’,$array); ?>

Thanks

if the array is static…then simply use





<?php echo $form->dropDownList($model,'naam',array('0' => 'User', '1' => 'Admin')); ?>




[color="#006400"]/* Moved from Showcase to General Discussion */[/color]