有人看到我做错了吗?
$brand['slug']
保存时是空的,所以我猜在查找查询中出了点问题。
提前致谢。
public function beforeSave() {
if (isset($this->data['Smartphone']['model'])) {
$brand = $this->Brand->find('first', array(
'conditions' => array(
'Brand.id' => $this->data['Smartphone']['brand_id']
)
));
$this->data['Smartphone']['slug'] = $brand['slug'].'-'.Inflector::slug(strtolower($this->data['Smartphone']['model']), '-');
}
return true;
}