1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| function modifierAction()
{
$this->view->nom = "Modifier un client";
$form = new FormulaireClients();
$form->submit->setLabel('Enregistrer');
$this->view->form = $form;
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
$clients = new Clients();
$id = (int)$form->getValue('id');
$row = $clients->fetchRow('id='.$id);
$row->nom = $form->getValue('nom');
$row->prenom = $form->getValue('prenom');
$row->save();
$this->_redirect('/');
} else {
$form->populate($formData);
}
} else {
// L'id de l'album est attendu dans $params['id']
$id = (int)$this->_request->getParam('id', 0);
if ($id > 0) {
$clients = new Clients();
$client = $clients->fetchRow('id='.$id);
$form->populate($client->toArray());
}
}
} |
Partager