Welcome Guest, Not a member yet? Register   Sign In
Unable to access an error message corresponding to your field name.
#1

[eluser]php beginner[/eluser]
Unable to access an error message corresponding to your field name.
this error occure while i use callback in rules
#2

[eluser]adamp1[/eluser]
By the sounds of things you have done the following:
Code:
$this->form_validation->set_rules('myfield', 'My Field', 'callback_isvalid');
..
..
// You then have a callback function in your controller
function isvalid($value)
{
  if(<some logic here>)
  {
    return TRUE:
  }
  else
  {
    return FALSE;
  }
}

The issue is you are missing the following line from the callback method.
Code:
$this->form_validation->set_message('myfield', 'The %s field is invalid');

For more information please see this user guide section http://ellislab.com/codeigniter/user-gui...tingerrors
#3

[eluser]php beginner[/eluser]
no i m nt missing that sentance
#4

[eluser]flaky[/eluser]
put the code here, to see what you are missing
#5

[eluser]theshiftexchange[/eluser]
[quote author="adamp1" date="1270641494"]By the sounds of things you have done the following:
Code:
$this->form_validation->set_rules('myfield', 'My Field', 'callback_isvalid');
..
..
// You then have a callback function in your controller
function isvalid($value)
{
  if(<some logic here>)
  {
    return TRUE:
  }
  else
  {
    return FALSE;
  }
}

The issue is you are missing the following line from the callback method.
Code:
$this->form_validation->set_message('myfield', 'The %s field is invalid');
[/quote]

Actually thats slightly wrong. It should be:

Code:
$this->form_validation->set_message ('isvalid', 'The %s field is invalid');

The $this->form_validation->set_message name needs to be the name of your callback function - NOT your variable name. If you set it to the variable name it gives the exact message the OP posted.

I know this because 30mis ago I had EXACTLY the same problem on one of my forms and worked out I'd done this
#6

[eluser]adamp1[/eluser]
@theshiftexchange: Yup your 100% correct, typo on my part.

If thats not the fix could you post the code for setting up the validation rules and your callback method.




Theme © iAndrew 2016 - Forum software by © MyBB