Question

Trying to use the modules: Jelly-Auth and Jelly-Formo is causing 2 errors. Depending on how I arrange my boostrap file I can get rid of one error or the other but not both...

Error 1: Auth works fine, formo doesn't: 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
  ));

Error 2: Formo works fine, auth breaks on 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
));

Any help would be highly appreciated... thanks...

Update: I got Error 2 fixed in a hackish kind of way... a better method would be appreciated...

I simply commented out line 81 and 82 of formo-jelly/classes/jelly/model.php

I'd like to be able to use jelly-formo validation... but as it's causing problems with Auth validation right now... I'm willing to scrap those two lines for the time being...

81: if ( ! $this->form->validate(TRUE))
82:     throw new Validator_Exception($this->form->errors(), 'Failed to validate form');
Was it helpful?

Solution

The incompatibility between the modules comes from 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');

Here's my change, I didn't tested thoughtfully as I am only starting to use 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');
}

patch: https://github.com/gimpe/kohana-formo-jelly/commit/e95df23ced9647f41f70f18244dc1794ba7c6bc1

OTHER TIPS

You should always use try...catch() blocks when saving Jelly objects:

try {
    $model->save();
    // object saved successfully
}
catch (Validate_Exception $e)
{
    // get validation errors
    $errors = $e->array->errors();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top