尝试使用模块: Jelly-Auth 和 Jelly-Formo 导致2个错误。根据我如何安排我的boostrap文件,我可以摆脱一个错误或另一个错误,但不是两个...
错误1:Auth工作正常,formo不能: http://wellcommentedcode.com/stack_questions/formo.jpg
Kohana::modules(array(
'database' => MODPATH.'database', // Database access
'jelly' => MODPATH.'jelly', // Jelly ORM
'jelly-auth' => MODPATH.'jelly-auth', // Basic authentication & Jelly
'auth' => MODPATH.'auth', // Basic authentication
'formo-jelly' => MODPATH.'formo-jelly', // Easy forms & Jelly
'formo' => MODPATH.'formo', // Easy forms
));
错误2:Formo工作正常,验证时auth中断: http://wellcommentedcode.com/stack_questions/formo-auth.jpg
Kohana::modules(array(
'database' => MODPATH.'database', // Database access
'formo-jelly' => MODPATH.'formo-jelly', // Easy forms & Jelly
'formo' => MODPATH.'formo', // Easy forms
'jelly' => MODPATH.'jelly', // Jelly ORM
'jelly-auth' => MODPATH.'jelly-auth', // Basic authentication & Jelly
'auth' => MODPATH.'auth', // Basic authentication
));
任何帮助都将受到高度赞赏......谢谢......
更新 我以一种hackish方式修复了错误2 ...一个更好的方法将不胜感激...
我只是评论了 formo-jelly / classes / jelly / model.php第81和82行
我希望能够使用jelly-formo验证......但是因为它现在导致Auth验证问题...我愿意暂时废弃这两行......
81: if ( ! $this->form->validate(TRUE))
82: throw new Validator_Exception($this->form->errors(), 'Failed to validate form');
答案 0 :(得分:1)
模块之间的不兼容性来自kohana-formo-jelly / classes / jelly / model.php:
// If the formo object to validate against doesn't exist, make it
$this->generate_form();
if (!$this->form->validate(TRUE))
throw new Validator_Exception($this->form->errors(), 'Failed to validate form');
这是我的改变,我没有仔细测试,因为我只是开始使用jelly-auth / formo:
if (isset($this->form))
{
// If the formo object to validate against doesn't exist, make it
$this->generate_form();
if (!$this->form->validate(TRUE))
throw new Validator_Exception($this->form->errors(), 'Failed to validate form');
}
补丁:https://github.com/gimpe/kohana-formo-jelly/commit/e95df23ced9647f41f70f18244dc1794ba7c6bc1
答案 1 :(得分:0)
保存Jelly对象时应始终使用try...catch()
块:
try {
$model->save();
// object saved successfully
}
catch (Validate_Exception $e)
{
// get validation errors
$errors = $e->array->errors();
}