Welcome Guest, Not a member yet? Register   Sign In
Element Specific Custom Errors
#1

[eluser]lightnb[/eluser]
I found a few posts asking this question, but none with a definite answer...

How can I do this:

Code:
$this->validation->set_message('required', 'Please enter your %s.'); // Generic rule

// Overrides generic rule for specific fields...
$this->validation->set_message('required', 'password', 'Please pick a password');
$this->validation->set_message('required', 'passwordconf', 'Please confirm your password.');

Explanation of pseudo code:

Line 1 creates a generic, custom error message for the "required" rule, which applies to all fields.

Line 4 overrides the generic "required" message, but only for the field named "password".
Line 5 overrides the generic "required" message, but only for the field named "passwordconf".
#2

[eluser]Khoa[/eluser]
This is also what I'm looking for, but there seems no final answer yet. This looks like the solution, but I didn't try it out yet: http://ellislab.com/forums/viewthread/88136/
#3

[eluser]lightnb[/eluser]
I did actually work around this problem. I don't remember the details, but I modified the built-in validation library so that the set_message function takes three arguments, like my example above.
#4

[eluser]Khoa[/eluser]
That's good. So do need to modify the default validation class a lot? I think it might be better to extend the built-it class with our one to ensure compatibility later on when new CI version comes out. That's the theory, not sure how to do t yet :-) Do you mind to have a look at it again and share those codes here?
#5

[eluser]lightnb[/eluser]
I've tried uploading the Library file for you, but the system won't let me upload .php files.

Which is kind of stupid because this is a php forum... Maybe the administrators can enable php file attachments?



In your view, you'll need to use the extended error's name, like:

Code:
<? if(isset($this->validation->error_email_required)) echo $this->validation->error_email_required;?>
<? if(isset($this->validation->error_email_valid_email)) echo $this->validation->error_email_valid_email;?>
<? if(isset($this->validation->error_email__checkDuplicateEmail)) echo $this->validation->error_email__checkDuplicateEmail;?>
#6

[eluser]Khoa[/eluser]
Uhm, I can see the point where you come from. I think they block php files for security purpose. Why don't you rename the file to .txt and upload it? Or might be just zip it first.
#7

[eluser]lightnb[/eluser]
[quote author="Khoa" date="1219118993"]Why don't you rename the file to .txt and upload it?[/quote]

I tried that, the system is too 'smart'!

It says that the contents of the file don't match it's mime type...

Yeah, I guess I can zip it. It's just a bunch of extra steps since I have to copy it down from the server, zip then upload, instead of just uploading directly... :roll:

Anyway, File is attached.

Just unzip and drop in application/libraries. The system will grab that one instead of the original. Let me know if it works for you. Smile
#8

[eluser]Khoa[/eluser]
LOL! That's something I thought about this morning (seriously!). I thought: "why would the website check the content of a text file for? It's not going to execute it is it? So a .txt file should work!" Hahaha, what a "clever" system! Thanks, I will surely test it out and let you know ;-)




Theme © iAndrew 2016 - Forum software by © MyBB