Élimination de form->check() pour version 1.3
This commit is contained in:
parent
0ed03eb362
commit
2454883ffc
4 changed files with 150 additions and 209 deletions
|
|
@ -16,38 +16,27 @@ if (!$c)
|
|||
throw new UserException("Ce client n'existe pas.");
|
||||
}
|
||||
|
||||
if(f('save'))
|
||||
{
|
||||
$form->check('edit_client', [
|
||||
'nom' => 'required|string',
|
||||
'adresse' => 'required|string',
|
||||
'code_postal' => 'required|string',
|
||||
'ville' => 'required|string',
|
||||
'telephone' => 'string',
|
||||
'email' => 'email'
|
||||
]);
|
||||
$form->runIf(f('save') && !$form->hasErrors(),
|
||||
function () use ($client, $id)
|
||||
{
|
||||
try
|
||||
{
|
||||
$r = $client->edit($id,[
|
||||
'nom' => f('nom'),
|
||||
'adresse' => f('adresse'),
|
||||
'code_postal' => f('code_postal'),
|
||||
'ville' => f('ville'),
|
||||
'telephone' => f('telephone'),
|
||||
'email' => f('email')
|
||||
]);
|
||||
|
||||
if (!$form->hasErrors())
|
||||
{
|
||||
try
|
||||
{
|
||||
$r = $client->edit($id,[
|
||||
'nom' => f('nom'),
|
||||
'adresse' => f('adresse'),
|
||||
'code_postal' => f('code_postal'),
|
||||
'ville' => f('ville'),
|
||||
'telephone' => f('telephone'),
|
||||
'email' => f('email')
|
||||
]);
|
||||
|
||||
$r ? Utils::redirect(PLUGIN_ADMIN_URL . 'client.php?id='.(int)$id):'';
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
$r ? Utils::redirect(PLUGIN_ADMIN_URL . 'client.php?id='.(int)$id):'';
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}, 'edit_client');
|
||||
|
||||
|
||||
$tpl->assign('client', $c);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue