Welcome Guest, Not a member yet? Register   Sign In
Custom Form Validation nightmare
#11

[eluser]Stuey[/eluser]
I've had a similar problem in the past, it was purely because I didn't prepend "callback_" in my set_rules parameters. :roll:

I could be wrong here, but I'm sure I read somewhere it sometimes has problems with callback functions that have too many underscores in the function name.
#12

[eluser]Davcon[/eluser]
I hear you buddy.

I suppose the most positive spin we can put on this is to say that it's such a new technology that we're all still trying to figure it out.

By the way, the PHPcake way of doing things is a joke. If you think we've got it bad you should check out what those guys are having to put up with.
#13

[eluser]Dennis Rasmussen[/eluser]
Ditch CodeIgniter?
I don't see a problem with the form validation or the documentation, so I don't see a reason why that would be a reason to ditch CI.

If it was a bug.. sure, but when it isn't... meh
#14

[eluser]Davcon[/eluser]
I created a couple of posts in which I've talked rubbish. I can't delete them, so one is a dot and the other is this.

Anyway...


Form validation is arguably the single most important thing that any web developer can do. Get it wrong and the results could destroy your business. If you or I can't do form validation and do it well then the only responsible thing to do is to quit. It's that important. At least, that's how I see things.


I'm not entirely sure what went wrong for me today. I think it was to do with the callback function. I had it being used as a function within a function (or should that be a method within a method?) and it wasn't working.

Anyway, it was a nightmare. It cost me a whole day and I'm just glad it's over. Thanks for your help.
#15

[eluser]Davcon[/eluser]
.
#16

[eluser]Josh Campbell[/eluser]
This whole topic is amusing at best. I hope that no one passes any judgment on CI based on the information here.
Aside from the fact that the form validation works exactly as described in the user guide, the best part about CI is that if something does not work the way you need it to you just extend, replace, or create your own functionality from scratch.

Take for instance my need to retrieve error messages and field id's (highlight) via ajax. Of course the form validation does not have this functionality by design because it is made for use on standard forms. But after a 30 second glance at the Form_validation library I new exactly what to do in order to get what I needed.

And this was it:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Form_validation extends CI_Form_validation
{    
    function get_errors_array()
    {
        return $this->_error_array;
    }

    /**
     * Get Error Messages
     *
     * Gets the error message for all fields
     *
     * @access    public
     * @return    array
     */
    function get_error_messages()
    {    
        $message_temp = array('highlight' => '');
        
        if ( ! empty($this->_error_array))
        {
            $fields = array_keys($this->_error_array);
            foreach ($fields as $field)
            {
                $message_temp[$field . '_error'] = $this->_error_prefix .
                    $this->_field_data[$field]['error'] . $this->_error_suffix;
                $message_temp['highlight'] .= '#' . $field . ',';
            }
            $message_temp['highlight'] = trim($message_temp['highlight'], ',');
            
            return $message_temp;
        }
        else
        {
            return FALSE;
        }
    }
}


Changing frameworks based on functionality that is not even part of the core is just silly. That would be like hating CakePHP because something you got out of the Bakery that sucked. lol (fyi CI > Cake + Symphony * Zend)
#17

[eluser]Davcon[/eluser]
I got it wrong.

My callbacks weren't working because I thought I could use them as a method within a method. Now I know better.

It was my mistake and the manual isn't that bad, after all.

I'm just a learner here so go easy on me, dude. I'm doing my best here.

If I could delete this thread I would but I'm not able to.
#18

[eluser]Josh Campbell[/eluser]
Don't sweat it David! We have all made posts like this at one time or another.
Especially when your learning something new it's easy to get tunnel vision and over look the simple explanation to the seemingly insane problem in front of you. Smile

But every mistake is a learning experience, this one might help someone else in some small way down the road so it's good to leave them up. Otherwise we would all delete what we think are dumb questions on our part.

Happy coding!
#19

[eluser]Davcon[/eluser]
Thank you for such a positive message!
#20

[eluser]Dennis Rasmussen[/eluser]
Cheer up buddy!
I'm not afraid to admit I've had the same experience as you did, but that was in the past.

CI is great, don't abandon it just yet Wink




Theme © iAndrew 2016 - Forum software by © MyBB