Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add support for per field/rule error messages to the Form Validation Library #1252

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
3 participants

This commit gives the ability to pass an associative array of error
message as the fourth parameter of the set_rules method. This adds a
simple way to pass field/input specific error messages rather than rule
specific messages that set_messsage provides.

@jbottigliero jbottigliero Add support for 'flash error messages' to the Form Validation Library
This commit gives the ability to pass an associative array of error
message as the third parameter of the set_rules method. This adds a
simple way to pass field/input specific error messages rather than rule
specific messages that set_messsage provides.
03f52d2

jbottigliero added some commits Apr 12, 2012

@jbottigliero jbottigliero Revert "Add support for 'flash error messages' to the Form Validation…
… Library"

This reverts commit 03f52d2.
74764a6
@jbottigliero jbottigliero Add support for field specific Form Validation error messages
This commit seems to make more sense, and is a bit more elegant. Adds a
third parameter to the set_message method of the Form Validation
library which will allow the ability to set field specific error
messages "on the fly"!
b9a7876

@jbottigliero jbottigliero reopened this Apr 12, 2012

The second set of commits moves this functionality from the set_rules method to the set_messages method which makes more sense when reading the code.


$this->load->library('form_validation');

$this->form_validation->set_rules('name', 'name', 'required');
$this->form_validation->set_rules('email', 'email', 'required');
$this->form_validation->set_message(
  'required', 
  'Hey, we need to know what to call you by!', 
  'name'
);

@cryode cryode commented on an outdated diff Apr 14, 2012

system/libraries/Form_validation.php
{
+ if($name){
@cryode

cryode Apr 14, 2012

Contributor

Should always do more specific IF checks than this. For instance, '0' will be interpreted as false, even though it's a valid string.

Contributor

narfbg commented Jan 6, 2014

Really outdated and given the lack of comments - most likely not that useful, I can't think of a use case for it.

@narfbg narfbg closed this Jan 6, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment