tthai1980
(Tthai1980)
March 7, 2009, 6:44am
1
I have a class Content extends CActiveRecord.
Then I have Page extends Content.
$page = new Page;
I send $page to a form view.
Now when I submit that form,
The controller code has if(iiset($_POST['Page'])) {…
However, $_POST['Page'] does not exist. What exists is $_POST['Content'].
It looks like the activeR stuff sends the Parent Type and not the Child Type I originally declared.
How do I approach this so that the proper Child type is submitted to the Controller?
qiang
(Qiang Xue)
March 7, 2009, 1:03pm
2
I don't think that's possible. Could you please double check?
The name of input fields is determined based on CHtml::resolveName() using a get_class($model) call.
tthai1980
(Tthai1980)
March 7, 2009, 5:41pm
3
Thanks Qiang,
I didn't have this method in my Page class.
public static function model($className=__CLASS__)
{
return parent::model($className);
}
So it was referring to the Content class one instead.
hung5s
(Hung5s)
March 7, 2009, 6:00pm
4
Replace CLASS by 'Page' or when you call Page::mode(), you should call like this: Page::mode('Page').
What will cause problem is the derived class use a very common name, Page. I think the naming convention should be: ContentModel (for generated AR class) and Content extends ContentModel.