Welcome Guest, Not a member yet? Register   Sign In
Matchbox & CI 1.7 Working Form Validation

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



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

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.


Sure.. first thing i did was update _ci_load_class with dexcell's update (although i dont think it effects the library loading.

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.


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

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.

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

Please, look in form_helper.php function &_get_validation_object()
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

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

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

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


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.

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. : )

Very happy to find this post. Was wondering why validation errors were not appearing


can you update your code to include this bug fix:

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

Theme © iAndrew 2016 - Forum software by © MyBB