Yii Framework Forum: change function name and then does not have a method named ** - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

change function name and then does not have a method named ** When I change the name of a method in form view and model I get error Rate Topic: -----

#1 User is offline   got 2 doodle 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 248
  • Joined: 12-December 08
  • Location:Beautiful Nova Scotia, Canada

Posted 24 October 2009 - 01:34 PM

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

Quote

CException
Description

WebPage does not have a method named "somethingelse".


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
Check out myYii powered website
0

#2 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 24 October 2009 - 01:38 PM

Try deleting the files under the protected/runtime directory
It has happened too me a couple of times after changing some function names
0

#3 User is offline   got 2 doodle 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 248
  • Joined: 12-December 08
  • Location:Beautiful Nova Scotia, Canada

Posted 24 October 2009 - 02:33 PM

View PostSpyros, on 24 October 2009 - 01:38 PM, said:

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
Check out myYii powered website
0

#4 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 24 October 2009 - 03:13 PM

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'));
 ?>

0

#5 User is offline   got 2 doodle 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 248
  • Joined: 12-December 08
  • Location:Beautiful Nova Scotia, Canada

Posted 24 October 2009 - 04:45 PM

View PostSpyros, on 24 October 2009 - 03:13 PM, said:

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 :rolleyes:

doodle
Check out myYii powered website
0

#6 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 25 October 2009 - 02:55 AM

A correction:
it should be
<?php
public static function somethingelse() {
  $a = WebPage::model()->findAll();
  return $a;
}
?>

0

#7 User is offline   got 2 doodle 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 248
  • Joined: 12-December 08
  • Location:Beautiful Nova Scotia, Canada

Posted 27 October 2009 - 07:39 AM

View PostSpyros, on 25 October 2009 - 02:55 AM, said:

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
Check out myYii powered website
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users