Better error management when add/update extrafield
Usage of setEventMessage() function
This commit is contained in:
parent
55757a6b82
commit
013eac1147
@ -76,8 +76,6 @@ dol_fiche_head($head, 'attributes', $langs->trans("Member"), 0, 'user');
|
||||
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
|
||||
print '<br>';
|
||||
|
||||
dol_htmloutput_errors($mesg);
|
||||
|
||||
// Load attribute_label
|
||||
$extrafields->fetch_name_optionals_label($elementtype);
|
||||
|
||||
|
||||
@ -77,8 +77,6 @@ dol_fiche_head($head, 'attributes_type', $langs->trans("Member"), 0, 'user');
|
||||
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
|
||||
print '<br>';
|
||||
|
||||
dol_htmloutput_errors($mesg);
|
||||
|
||||
// Load attribute_label
|
||||
$extrafields->fetch_name_optionals_label($elementtype);
|
||||
|
||||
|
||||
@ -78,8 +78,6 @@ dol_fiche_head($head, 'attributes', $langs->trans("Agenda"));
|
||||
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
|
||||
print '<br>';
|
||||
|
||||
dol_htmloutput_errors($mesg);
|
||||
|
||||
// Load attribute_label
|
||||
$extrafields->fetch_name_optionals_label($elementtype);
|
||||
|
||||
|
||||
@ -76,8 +76,6 @@ dol_fiche_head($head, 'attributes', $langs->trans("Propal"), 0, 'propal');
|
||||
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
|
||||
print '<br>';
|
||||
|
||||
dol_htmloutput_errors($mesg);
|
||||
|
||||
// Load attribute_label
|
||||
$extrafields->fetch_name_optionals_label($elementtype);
|
||||
|
||||
|
||||
@ -77,8 +77,6 @@ dol_fiche_head($head, 'attributes', $langs->trans("Invoices"), 0, 'invoice');
|
||||
|
||||
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
|
||||
|
||||
dol_htmloutput_errors($mesg);
|
||||
|
||||
// Load attribute_label
|
||||
$extrafields->fetch_name_optionals_label($elementtype);
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ if ($action == 'add')
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Type"));
|
||||
$mesg[]=$langs->trans("ErrorFieldRequired",$langs->trans("Type"));
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
@ -49,21 +49,21 @@ if ($action == 'add')
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$mesg=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
|
||||
$mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
|
||||
$action = 'create';
|
||||
}
|
||||
if (GETPOST('type')=='int' && $extrasize > $maxsizeint)
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$mesg=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
|
||||
$mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
|
||||
$action = 'create';
|
||||
}
|
||||
if (GETPOST('type')=='select' && !GETPOST('param'))
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$mesg=$langs->trans("ErrorNoValueForSelectType");
|
||||
$mesg[]=$langs->trans("ErrorNoValueForSelectType");
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
@ -84,6 +84,7 @@ if ($action == 'add')
|
||||
$result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$default_value,$params);
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessage($langs->trans('SetupSaved'));
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
}
|
||||
@ -91,6 +92,7 @@ if ($action == 'add')
|
||||
{
|
||||
$error++;
|
||||
$mesg=$extrafields->error;
|
||||
setEventMessage($mesg,'error');
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -98,9 +100,14 @@ if ($action == 'add')
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
|
||||
setEventMessage($mesg,'error');
|
||||
$action = 'create';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($mesg,'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,21 +121,21 @@ if ($action == 'update')
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Type"));
|
||||
$mesg[]=$langs->trans("ErrorFieldRequired",$langs->trans("Type"));
|
||||
$action = 'create';
|
||||
}
|
||||
if (GETPOST('type')=='varchar' && $extrasize > $maxsizestring)
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$mesg=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
|
||||
$mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
|
||||
$action = 'edit';
|
||||
}
|
||||
if (GETPOST('type')=='int' && $extrasize > $maxsizeint)
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$mesg=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
|
||||
$mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
|
||||
$action = 'edit';
|
||||
}
|
||||
|
||||
@ -148,6 +155,7 @@ if ($action == 'update')
|
||||
$result=$extrafields->update($_POST['attrname'],$_POST['label'],$_POST['type'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$pos,$params);
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessage($langs->trans('SetupSaved'));
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
}
|
||||
@ -155,6 +163,7 @@ if ($action == 'update')
|
||||
{
|
||||
$error++;
|
||||
$mesg=$extrafields->error;
|
||||
setEventMessage($mesg,'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -162,8 +171,13 @@ if ($action == 'update')
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
|
||||
setEventMessage($mesg,'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($mesg,'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -76,8 +76,6 @@ dol_fiche_head($head, 'attributes_contacts', $langs->trans("ThirdParties"), 0, '
|
||||
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
|
||||
print '<br>';
|
||||
|
||||
dol_htmloutput_errors($mesg);
|
||||
|
||||
// Load attribute_label
|
||||
$extrafields->fetch_name_optionals_label($elementtype);
|
||||
|
||||
|
||||
@ -77,8 +77,6 @@ dol_fiche_head($head, 'attributes', $langs->trans("ThirdParties"), 0, 'company')
|
||||
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
|
||||
print '<br>';
|
||||
|
||||
dol_htmloutput_errors($mesg);
|
||||
|
||||
// Load attribute_label
|
||||
$extrafields->fetch_name_optionals_label($elementtype);
|
||||
|
||||
|
||||
@ -76,8 +76,6 @@ dol_fiche_head($head, 'attributes', $langs->trans("User"), 0, 'user');
|
||||
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
|
||||
print '<br>';
|
||||
|
||||
dol_htmloutput_errors($mesg);
|
||||
|
||||
// Load attribute_label
|
||||
$extrafields->fetch_name_optionals_label($elementtype);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user