I'm not sure how I should phrase this, so pardon me for my lack of narrative..
Here's an approximate form of my current code, trimmed down to the essentials of the problem (PHP v5.2 / CodeIgniter v1.7):
In system/application/config/form_validation.php
, I have a rule that looks like this:
'some_controller/save' => array(
array(
'field' => 'some_code',
'label' => 'Some Code Name',
'rules' => 'trim|required|min_length[1]|max_length[6]|callback__unique_codename'
),
),
In system/application/controllers/some_controller.php
, I have the custom callback function needed by the above validation rule:
function _unique_codename($codename)
{
$result = $this->some_code_model->find_by_codename($codename); // this returns NULL if the codename is not found
if ($result)
{
$this->form_validation->set_message('_unique_codename', '%s already exists. Please enter another %s.');
return FALSE;
}
else
{
return TRUE;
}
}
After form submission and an error occurs, the message displayed is: "Some Code Name already exists. Please enter another ."
Is there any way to evaluate multiple "%s" instances in the error message?