0

尝试使用模块:Jelly-AuthJelly-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 工作正常,验证中断: 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
));

任何帮助将不胜感激...谢谢...

更新: 我以一种骇人听闻的方式修复了错误 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');
4

2 回答 2

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

于 2010-11-26T16:29:30.007 回答
0

try...catch()保存 Jelly 对象时应始终使用块:

try {
    $model->save();
    // object saved successfully
}
catch (Validate_Exception $e)
{
    // get validation errors
    $errors = $e->array->errors();
}
于 2010-09-16T06:44:14.397 回答