This is bizare
I want a drop down in my form populated from a table
The model is called WebPage.php
in the model I create two functions they are identical except for name
public function something()
{
$a = $this->findAll();
return $a;
}
public function somethingelse()
{
$a = $this->findAll();
return $a;
}
In the form partial view the following code works
<?php
echo CHtml::activeDropDownList($model,'KeyphrasePagePage',CHtml::listData(WebPage::model()->something(),'WebPageID','WebPageName'));
?>
The following code does not work
<?php
echo CHtml::activeDropDownList($model,'KeyphrasePagePage',CHtml::listData(WebPage::model()->somethingelse(),'WebPageID','WebPageName'));
?>
It gives the following error
It’s like something is not being re-initialized or something is cached, I am confused!!
I cleared the browser cache. Closed the browser tab, logged out of the session, weird!
Specs:Yii version 1.1a
Server:apache2
OS:linux
Browser:firefox
Thanks for any help you can give me
doodle
Spyros
(Spyros)
October 24, 2009, 6:38pm
2
Try deleting the files under the protected/runtime directory
It has happened too me a couple of times after changing some function names
Thanks, I tried what you suggested, but the same result.
I’ll keep digging.
doodle
Spyros
(Spyros)
October 24, 2009, 8:13pm
4
Maybe you should try
<?php
public static function somethingelse() {
$a = WebPage::findAll();
return $a;
}
?>
<?php
echo CHtml::activeDropDownList($model,'KeyphrasePagePage',CHtml::listData(WebPage::somethingelse(),'WebPageID','WebPageName'));
?>
Spyros:
Maybe you should try
<?php
public static function somethingelse() {
$a = WebPage::findAll();
return $a;
}
?>
<?php
echo CHtml::activeDropDownList($model,'KeyphrasePagePage',CHtml::listData(WebPage::somethingelse(),'WebPageID','WebPageName'));
?>
Thanks spyros, I will try that when I am back at work on Tuesday
doodle
Spyros
(Spyros)
October 25, 2009, 7:55am
6
A correction:
it should be
<?php
public static function somethingelse() {
$a = WebPage::model()->findAll();
return $a;
}
?>
As usual I feel like a complete idiot now that I know what the problem was. I should probably be keeping it simpler while I am learning Yii but I set up my installation according to this cookbook article Organize directories for applications with front-end and back-end. Anyway to make a long story short, I had two model directories /protected/models/ and /protected/backend/models/ I had two WebPage.php files one in each models directory. I seems Yii was reading the /protected/models/ version while I was changing the /protected/backend/models/ version.
Not too smart I did however learn a lot through my investigations, thanks for your help spyros.
doodle