10390 Posts in 2202 Topics by 1712 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 517 Views |
-
[SOLVED] Controller does not hold correct Model!?!

12 August 2010 at 9:11pm Last edited: 13 August 2010 12:04am
Hello,
I created a new page MyNewPage by extending UserDefinedForm and created the controller (extending UserDefinedForm_Controller) too. The page itself contains getter-methods to access the db-fields. A new site in CMS was created.
By sending an AJAX-Request, handled in the controller, I want to access this getter-method by
$this->data()->myGetter();
I got an error message "Object->__call(): the method 'myGetter' does not exist on 'Page'. I am wondering about the resulting type of $this->data() beeing type Page. I expected the page type MyNewPage.
By investigating the situation, I found a code snippet in the constructor of ContentController. At this point (line 41 in v2.4.1), the class-variable $dataRecord is set = new Page(); if the dataRecord was not given as parameter. I don´t understand this relation, why $dataRecord is not set to the correct model-instance of MyNewPage.I think, the problem is related to the AJAX-url, with which the determination of a concrete instance is not possible. Is the only solution to determine the dataObject by myself in handling the AJAX-Request?
Best regards,
chrclaus -
Re: [SOLVED] Controller does not hold correct Model!?!

13 August 2010 at 12:03am
Hello,
I found the problem by myself - sometimes it´s a good idea to write a problem down to a paper to get a different point of view ;-).
The problem is the url, specified in the AJAX-request. I used the url MyNewPage_Controller/action with which it is not possible to determine a concrete dataobject. After switching to the page-link /mysites/mynewpage/action the underlying data-model is set correctly.
Best regards,
chrclaus
| 517 Views | ||
|
Page:
1
|
Go to Top |

