在 CakePHP 2.x 中使用 Model::saveAssociated() 显示 hasMany 关联的验证错误的最简单方法是什么?
这是 CakePHP 食谱中的一个示例。(http://book.cakephp.org/2.0/en/models/saving-your-data.html#saving-related-model-data-hasone-hasmany-belongsto)
echo $this->Form->create('Company', array('action' => 'add'));
echo $this->Form->input('Company.name', array('label' => 'Company name'));
echo $this->Form->input('Company.description');
echo $this->Form->input('Company.location');
echo $this->Form->input('Account.0.name', array('label' => 'Account name'));
echo $this->Form->input('Account.0.username');
echo $this->Form->input('Account.0.email');
echo $this->Form->end('Add');
例如,当验证 Account.0.email 失败时,表单字段似乎不会自动失效。虽然错误在 $this->Company->Account->validationErrors 中列出。
有没有办法自动使相应的字段无效并显示相应的验证错误?