CodeIgniter Forums
Matchbox & CI 1.7 Working Form Validation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: Matchbox & CI 1.7 Working Form Validation (/thread-12867.html)

Pages: 1 2


Matchbox & CI 1.7 Working Form Validation - El Forum - 11-02-2008

[eluser]philpalmieri[/eluser]
Hey guys,

Please use at your own risk, but i hacked together an update Loader.php that allows form validation to work with latest CI and latest matchbox.

Just replace your application/libraries/Loader.php with this, and it should work

http://page12.com/ci/Loader.php.txt


Matchbox & CI 1.7 Working Form Validation - El Forum - 11-03-2008

[eluser]dexcell[/eluser]
Thanks


Matchbox & CI 1.7 Working Form Validation - El Forum - 11-08-2008

[eluser]Edmundas KondraĊĦovas[/eluser]
Hi!

I was having a problem with validation_errors() function as it was not working at all. I found out that Matchbox was behind this problem and here I am writing in this thread. Could you walk through your hacked version of Loader.php? I did some changes myself to this file (not related to new form validation), so I would like to know what exactly has been changed.

Thanks in advance.


Matchbox & CI 1.7 Working Form Validation - El Forum - 11-09-2008

[eluser]philpalmieri[/eluser]
Hi,

Sure.. first thing i did was update _ci_load_class with dexcell's update (although i dont think it effects the library loading.
http://ellislab.com/forums/viewthread/65749/P350/#480924

Then i updated _ci_init_class, Matchbox's method doesnt have reference to the new $object_name parameter, so i just ignore it and force the load as if its null by setting the $classvar.

This may still prevent it from working with subdirectories.

The reason this is all happening is because CI switched from loading the loaded libraries names into an normal array $this->_ci_classes, where all the load calls are using if(in_array()... and now they are using key value pairs with the library obj name as a string key. - problem is, Matchbox isnt updated yet, so its still doign in_array calls as apposed to array_key_exists.

I'm not sure why it's only affecting the form_validation, but it is.

Not sure if that helps at all, and keep in mind this was the first time i cracked open matchbox, so i may have inadvertently affected something else.

Phil


Matchbox & CI 1.7 Working Form Validation - El Forum - 11-10-2008

[eluser]Edmundas KondraĊĦovas[/eluser]
Thanks for a detailed explanation, Phil. Wink


Matchbox & CI 1.7 Working Form Validation - El Forum - 12-10-2008

[eluser]hyperfire[/eluser]
I really would like to see more information about this subject.
Im using matchbox and CI and form_validation does not give me any msg at all.
Ill try this fix then post back here.


Matchbox & CI 1.7 Working Form Validation - El Forum - 01-20-2009

[eluser]DyaGa[/eluser]
[quote author="philpalmieri" date="1226278717"]
I'm not sure why it's only affecting the form_validation, but it is.
[/quote]

Please, look in form_helper.php function &_get_validation_object()
Code:
function &_get_validation_object()
    {
        $CI =& get_instance();

        // We set this as a variable since we're returning by reference
        $return = FALSE;

        if ( ! isset($CI->load->_ci_classes) OR  ! isset($CI->load->_ci_classes['form_validation']))
        {
            return $return;
        }
[...some code...]
    }

with Matchbox 0.9.4 the result of code
Code:
isset($CI->load->_ci_classes['form_validation'])

is FALSE. So, the returning validation object reference is FALSE.

That's why
Code:
function validation_errors($prefix = '', $suffix = '')
    {
        if (FALSE === ($OBJ =& _get_validation_object()))
        {
            return '';
        }

        return $OBJ->error_string($prefix, $suffix);
    }

and

Code:
function form_error($field = '', $prefix = '', $suffix = '')
    {
        if (FALSE === ($OBJ =& _get_validation_object()))
        {
            return '';
        }

        return $OBJ->error($field, $prefix, $suffix);
    }

returns an empty string...

It seems that http://page12.com/ci/Loader.php.txt temporary solves this problem... Let's wait for new Matchbox version.


Matchbox & CI 1.7 Working Form Validation - El Forum - 01-22-2009

[eluser]E1M2[/eluser]
Thanks Phil, appreciate it. For 2 days I was wondering what the problem was with form_validation. Hope the official comes for 1.7 too. : )


Matchbox & CI 1.7 Working Form Validation - El Forum - 01-26-2009

[eluser]bd3521[/eluser]
Very happy to find this post. Was wondering why validation errors were not appearing


Matchbox & CI 1.7 Working Form Validation - El Forum - 01-27-2009

[eluser]BorisK[/eluser]
@philpalmieri,

can you update your code to include this bug fix:
http://ellislab.com/forums/viewthread/65749/P360/#498946

It allows your modules to have their own autoload.php file. For example:
/modules/module_name/config/autoload.php