Kohana: Jelly-Auth et Jelly-Formo ne jouent pas bien ensemble ... erreurs de cause
-
03-10-2019 - |
Question
Tenter d'utiliser les modules: Jelly-Auth et Jelly-Formo est à l'origine 2 erreurs. Selon la façon dont je dispose mon fichier boostrap je peux me débarrasser d'une erreur ou l'autre mais pas les deux ...
Erreur 1: Auth fonctionne très bien, formo ne compte pas: 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
));
Erreur 2: Formo fonctionne très bien, les pauses auth sur la validation: 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
));
Toute aide serait très appréciée ... merci ...
Mise à jour: Je suis Erreur 2 fixe dans un hackish genre de façon ... une meilleure méthode serait appréciée ...
J'ai simplement commenté la ligne 81 et 82 de formo-gelée / classes / gelée / model.php
Je voudrais pouvoir utiliser la validation gelée formo ... mais comme il est de causer des problèmes avec la validation Auth en ce moment ... Je suis prêt à la ferraille ces deux lignes pour le moment ...
81: if ( ! $this->form->validate(TRUE))
82: throw new Validator_Exception($this->form->errors(), 'Failed to validate form');
La solution
L'incompatibilité entre les modules vient des classes kohana-formo-gelée / / gelée / 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');
Voici mon changement, je ne l'ai pas testé pensivement que je ne fais que commencer à utiliser la gelée 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');
}
Patch : https://github.com/gimpe/kohana-formo- gelée / commit / e95df23ced9647f41f70f18244dc1794ba7c6bc1
Autres conseils
Vous devriez toujours utiliser des blocs de try...catch()
lors de l'enregistrement des objets Jelly:
try {
$model->save();
// object saved successfully
}
catch (Validate_Exception $e)
{
// get validation errors
$errors = $e->array->errors();
}