kiamoz
(Kiarashmozaffary)
1
hi there ,
I have this lisData function :
$a = CHtml::listData(hy_profile::model()->findAll($criteria2), 'id', 'lastname');
echo $form->dropDownList($model,'userID',$a);
my database has several columns … I’d like to get lastname and fristname from my database …
how could do it ?!
here is my criteria…
$criteria2=new CDbCriteria();
$criteria2->join = 'LEFT JOIN user_role u ON u.user_id = t.user_id ';
$criteria2->condition = "u.role_id = 5";
thanks in advance …
mmbalaa
(Mmbalasundaram)
2
try this
$criteria2=new CDbCriteria();
$criter->select='firstname,lastname';
$criteria2->join = 'LEFT JOIN user_role u ON u.user_id = t.user_id ';
$criteria2->condition = "u.role_id = 5";
kiamoz
(Kiarashmozaffary)
3
thank you for your replay , now how about this my droplist ?
$a = CHtml::listData(hy_profile::model()->findAll($criteria2), 'id', 'lastname');
where can i put displat lastname and firstname inside together ?
lalzada
(Lalzadamohmand)
4
echo $form->dropdownlist($model,'country', CHtml::listData(Country::model()->findAll(), 'value_field', 'text_field'));
in CHtml::listData , value_field is which you want to save to db and text_field is to display
in dropdown list . i think u can’t include more than two fields in dropdown list using CHtml::ListData()
but if you want to select more columns using criteria then the above reply of
mbala
is useful
mmbalaa
(Mmbalasundaram)
5
to show first and lastname in yii
<?php
$criteria2=new CDbCriteria;
$criteria2->select="userid,concat(firstname,' ',lastname) as firstname";
$newmodel=User::model()->findAll($criteria2);
?>
<div class="row">
<?php echo $form->label($model,'userid'); ?>
<?php echo $form->dropDownList($model,'firstname',CHtml::listData($newmodel,'userid','firstname')); ?>
</div>