i happen to a strange problem.
i have a model channel
class Channel extends CActiveRecord
public static function getChannels()
// TO DO STH.
and have a model News
class News extends CActiveRecord
public function defaultScope()
'with' => array(
public function relations()
'channel' => array(self::BELONGS_TO, 'Channel', 'channel_id'),
in crud, when i create a news, it’s fine.but i update a existed record, the “_form” can’t display when i use Channel::getChannels()
no error report, no debug report
when i comment defaultScope in Model News or Channel::getChannels(), it’s fine again.
so , how to fix it?
and Thank all first
$channelModel =new Channel();
$data = $channelModel->getChannel();
Thanks for reply
i think it can work but do not correct the underlying problem.
i hope figure out why this happen and how to avoid it
Could you show the code in "_form"?
How do you call Channel::getChannels()?
Hmm, did you say "Channel::getChannel()"? getChannel and getChannels are the different things. Which do you mean?
it’s a write mistake when i posted,
i use the Channel::getChannels() (not use __get())
how do i call this function, even i var_dump(Channel::getChannels()) the problem happen to me.
in the controller, i call Channel::getChannels() before load News model, it works.
after load, it error.
so the problem lock to use "with" => array("channel")
What do you do in Channel::getChannels()? Do you do something related to News model?
no，this function return a array for Channel::model()->findAll();
even the function do nothing, this problem still appear
Would you please show the minimum code that will reproduce the problem?
i try to move this problem to a new project but it’s not happen
now i use lazy load "Channel" to avoid this problem
whatever, thank u for discussion~
and i will figure out the reason for this situation
for this time i use ‘with’ => array(‘Channel’)…
this problem has gone out
really a strange situation, prehaps my IDE error i think…(such as sync code error)
thank u again~