• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validation ... callback doesn't get triggered

That is actually a quite good solution.

I was ok with the text the required-error gave, I just hated it that it would show an error message for every field. This pretty much solves my problem without doing something difficult (like the MY_Validation thing) because I'm kinda new with CI.

True but then he can't do his custom validation but FinalFrags problem makes me wonder if the validation library needs to have an option to group error messages into one custom error message. There are a few other scenarios i can think of where it can be useful. This is going on my todo list for my own validate library.
It already has the possibility to add custom error messages Wink

The only way to learn CI is to break it occasionally. Tongue

Yeah, but I'm not up to that level to write my own libraries and such.

About these libraries... I now have a bunch of custom functions that I use in my application. I put them in a file functions.php (and uploaded it in system/application/libraries), it looks like this:

if (!defined('BASEPATH')) exit('No direct script access allowed');

class Functions {
    function isLoggedIn() {
        if ($this->session->userdata('username')) {
            return true;
        return false;
    // more functions ...

To be able to use these functions I have added the following line to my autoload.php:

$autoload['libraries'] = array('database', 'session', 'functions');

When I now need a function, I call it like this:

if (Functions::isLoggedIn()) {
    // code here

Is this the right way to do it in CodeIgniter? Or am I doing it wrong?

it can be even simpler for FinalFrags situation if you use the error_string approach
if($this->validation->error_string != '')
   $this->validation->error_string = 'custom message';

Yes, but then I'd have 1 error message for ALL errors that may occur. That's not exactly what I want.

Can someone please look at my functions thing and give me some reply on that?

I generally install libraries that contain static methods as helpers ie: functions_helper.php

It's only a personal preference though, Libraries are intantiated when loaded, helpers are not.

Helper classes also have access to the CI super object whereas instantiated libraries do not.

the CI way for loaded libraries is

Ok, that about solveds all my question I have at the moment. Thanks guys, and a big thank you to the developers of CodeIgniter too, great work on this framework...

Congrats xwero you made 2000+ posts Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.