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

[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
#2

[eluser]dexcell[/eluser]
Thanks
#3

[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.
#4

[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/65...50/#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
#5

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

[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.
#7

[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.
#8

[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. : )
#9

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

[eluser]BorisK[/eluser]
@philpalmieri,

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

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




Theme © iAndrew 2016 - Forum software by © MyBB