PDA

View Full Version : [SOLVED] Error Message in newthread form


omardealo
03-26-2013, 07:05 PM
Hello ...

I add new filed in newthread form , this field will contain only numbers
i know how show filed in newthread template and save data in database

$this->validfields['user_contact'] = array(TYPE_STR, REQ_NO);


but i want know how i make this filed (user_contact) Necessary and show erorr massage if user not entry anything Or user entry letters, not numbers ...
like Error message thread title
you must enter a title / subject !



Thanks !

kh99
03-29-2013, 07:35 PM
You could try changing "REQ_NO" to "REQ_YES" and see if that does what you want.

omardealo
03-29-2013, 08:10 PM
i changing it in threadfpdata_start hook
$this->validfields['user_contact'] = array(TYPE_STR, REQ_YES);
Nothing happened , that's not i want
I want to make sure that the user writes the content in this field, and this field accepts numbers only
If the user does not fill the field number, stop the process of sending new thread OR stop editing the thread and shows him a message (There is an empty field and you must fill number)

like this photo in attachment

omardealo
03-30-2013, 10:08 PM
OKay ... I finally found the solution

hook : newpost_process


if ($type == 'thread')
{
// check the data of filed (Content is not empty and also only numbers)
if (! is_numeric ($vbulletin->GPC['user_contact']) || $vbulletin->GPC['user_contact'] == '')
{
// Here is the error message
$dataman->error('user_contact_msgerror');
}else{
$dataman->setr('user_contact', htmlspecialchars_uni($post['user_contact']));
}
}


Thank you , kh99