Do I need some more work, to get a select box with the corresponding data (e.g. land list from an another db-table) in the created insert form (via CRUD) or it is enough to define the relations in the models and yii would do this for me automatically?
Asked
Active
Viewed 469 times
0
-
I've tried it, with no effect and I've thought, may be I do something wrong. See here: http://www.yiiframework.com/forum/index.php/topic/48141-database-relations-in-myisam-no-innodb/. I you don't know it, you better keep quiet and do not troll!!! – Gabriel Oct 24 '13 at 08:09
-
1That is a good question, short and pregnant and a true expert could answer with a single word. Yea Telvin, please do not troll! – Oct 24 '13 at 08:15
-
1@user2819288: I would like to say sorry if my words made you felt attacked. You said you have tried and it did not work for you, but how could I know it, in a day there are many questions and even it's long question, it helps the reader see how your effort was. E2B: I did not troll, and btw, in normal case, you need expert answer for certain idea, just go with E2B http://stackexchange.com/. Eventually OP got his answer, it's good. – Telvin Nguyen Oct 24 '13 at 12:34
1 Answers
1
Since you haven't provided any code, let me show you with an example. Suppose we have a user table and a group table and need to select a group for a user which is selected with a select box.
In the user model you can have a function like
public function getGroupName()
{
return CHtml::listData(Group::model()->findAll();
}
In the form view of user create you can populate the select box like below:
<?php echo $form->dropDownListRow($User, 'group_id', $User->getGroupName(),array('prompt' => 'Select ...')); ?>

redGREENblue
- 3,076
- 8
- 39
- 57