Home > Newsletter, Blog, and Other Topics > Topic

Display department name instead of department id

Posted by markthien 
This forum is now read only. You can not log in or make any changes. Please use the new forum linked above.
As of March 14, 2011, this forum has been replaced and is permanently set to read-only mode. This means you can view any existing post but cannot open new posts or reply to existing ones. The new forum is located athttp://www.larryullman.com/forums/If you need to post a message, you'll need to register there. If you have to post in order to follow up on a thread started here, well, that's going to be a bit of a pain. I would recommend just posting the appropriate information, or copying the original text from here, or linking to your thread here. I apologize for the inconvenience but this purge will make for better forums in the long run. Thanks.
Display department name instead of department id
January 02, 2011 12:20PM
Hi Guys,

I am new to Yii. I have just downloaded and it's really cool. I go to


and wanted to change department to display name instead of id. Can anyone tell me how to change this please? thanks in advance!

Mark Thien
Re: Display department name instead of department id
January 03, 2011 05:50PM
You'll need to define the relation between employee and department, then refer to $model->department->name, replacing "department" with whatever name you've given that relation. I believe this exact idea is discussed in my series on Yii.

Best Wishes,

Writer/Web Developer/Instructor
Forum Moderator