PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Quickform : How to put a dynamic error message with addrule?

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> HTML
View previous topic :: View next topic  
Author Message
oxygenix



Joined: 22 Jul 2007
Posts: 7

PostPosted: Sun Jul 22, 2007 10:12 am    Post subject: Quickform : How to put a dynamic error message with addrule? Reply with quote

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" Sad

Does someone have an idea ?

Thanks

Phil
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1049

PostPosted: Sun Jul 22, 2007 3:23 pm    Post subject: Reply with quote

addFormRule() allows you to define a callback function and to define customized error messages.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> HTML All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software