Search code examples
kohanakohana-authjelly

Kohana: Jelly-Auth and Jelly-Formo won't play well together... cause errors


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');

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