I am new in Yii framework and have a question.
I have a table named 'node' which has these fields:
id
name
parent_id
parent_id contain id of parent of a node which exist in this table too.
I have created model,controller and view files using Gii interface. In view files id of parent is shown but I want to display parent name instead of its id .
I guess maybe I need to add a public property in model class of this table, so I would be access to it via ->parent_name in view files.
How can I do it ? what files should I change ?
Page 1 of 1
Add New Property In Model File Of A Active Record In Yii
#2
Posted 28 December 2012 - 09:32 AM
create a relation with name "parentNode" and then you can use $model->parentNode->name; in your views
#3
Posted 28 December 2012 - 09:43 AM
Hyprion, on 28 December 2012 - 09:32 AM, said:
create a relation with name "parentNode" and then you can use $model->parentNode->name; in your views
Thank you.
How can I involve it in controller to have it in views that user $dataProviders?
I mean how can I return it in ActiveDataProvider for example to have it in index and admin view files ?
Share this topic:
Page 1 of 1

Help












