 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
oxygenix
Joined: 22 Jul 2007 Posts: 7
|
Posted: Sun Jul 22, 2007 10:12 am Post subject: Quickform : How to put a dynamic error message with addrule? |
|
|
Hello everybody,
With addrule you put in general a static error message (ex. your username needs to have more than 4 caracters). But how can I put a dynamic error message (ex. your username has only 2 caractères if I entered 2 caractères)
| Code: | function test($dummy,$field) {
global $MESFONC;
$MESFONC=" GREAT MY VALUE HAS BEEN MODIFIED";
return false; // To gererate the error message
}
global $MESFONC;
$MESFONC ="OLD VALUE";
$form->registerRule('test','callback','test');
$form->addRule('IN_EMAIL','error message : '.$MESFONC, 'test');
if ($form->validate()) {
$form->process('traiteDonnees',false);
}
else {
echo "Message Post validate: $MESFONC";
$form->display();
}
|
In this example the $MESFONC value is changed but only after the $form->validate process. I have then "error message : OLD VALUE" instead of "error message : GREAT MY VALUE HAS BEEN MODIFIED"
Does someone have an idea ?
Thanks
Phil |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1210
|
Posted: Sun Jul 22, 2007 3:23 pm Post subject: |
|
|
| addFormRule() allows you to define a callback function and to define customized error messages. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|