在组件I中尝试访问Myprofile模型
class SignMeupComponent extends Object
public function register() {
$this->__isLoggedIn();
if (!empty($this->controller->data)) {
extract($this->settings);
$model = $this->controller->modelClass;
$this->controller->loadModel($model);
$this->controller->{$model}->Myprofile->save($this->controller->data);
$this->controller->data['Myprofile']['user_id'] = $this->controller->{$model}->id;
$this->controller->{$model}->set($this->controller->data);
if ($this->controller->{$model}->validates()) {
感谢任何建议
答案 0 :(得分:14)
$this->controller
。您必须手动保存对控制器的引用,例如在组件的initialize()
方法中:
public function initialize(&$controller, $settings = array()) {
$this->controller = $controller;
}
然后您应该能够访问控制器的属性和方法。