Fix: Check for duplicate must ignore spaces before and after

This commit is contained in:
Laurent Destailleur 2012-05-21 10:37:03 +02:00
parent 1725e5b591
commit 6cf8c5c102

View File

@ -198,15 +198,18 @@ if (empty($reshook))
$action = ($action=='add'?'create':'edit'); $action = ($action=='add'?'create':'edit');
} }
// Check for duplicate prof id
for ($i = 1; $i < 3; $i++) for ($i = 1; $i < 3; $i++)
{ {
$slabel="idprof".$i; $slabel="idprof".$i;
if (($_POST[$slabel] && $object->id_prof_verifiable($i))) $_POST[$slabel]=trim($_POST[$slabel]);
$vallabel=$_POST[$slabel];
if ($vallabel && $object->id_prof_verifiable($i))
{ {
if($object->id_prof_exists($i,$_POST["$slabel"],$object->id)) if($object->id_prof_exists($i,$vallabel,$object->id))
{ {
$langs->load("errors"); $langs->load("errors");
$error++; $errors[] = $langs->transcountry('ProfId'.$i, $object->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $_POST[$slabel]); $error++; $errors[] = $langs->transcountry('ProfId'.$i, $object->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel);
$action = ($action=='add'?'create':'edit'); $action = ($action=='add'?'create':'edit');
} }
} }