Bonjour,
En faite j'ai un souci concerne la mise à jour de donnée dans la table de la base de donnée lorsque je décocher la case à cocher dans le form
voilà mon code ;
1 2 3 4 5 6 7
| $emailnotification = new Zend_Form_Element_Checkbox('emailnotification ', 'emailnotification', array(
'checkedValue' => 1,
'uncheckedValue' => 0,
) );
$emailnotification->setLabel('emailnotification');
$emailnotification->setValue(1);
$this->addElement($emailnotification); |
et dans le controller :
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
| if($this->_request->isPost())
{
$formData = $this->getRequest()->getPost();
if($form->isValid($formData))
{
$contact = new Admin_Model_DbTable_Contact();
$data = array();
$data['idContact'] = $idContact;
$data['firstname'] = $form->getValue('firstname');
$data['lastname'] = $form->getValue('lastname');
$data['emailnotification'] = $form->getValue('emailnotification');
if($contact->editContact($data))
{
echo json_encode(array(
"response" => true,
"message" => "Contact " . $data['firstname'] . " " . $data['lastname'] . "a été modifié"
));
exit();
} else {
echo json_encode(array(
"response" => false,
"errorMessage" => "Il y a eu une erreur dans l'edition de Contact."
) );
exit();
}
}
} |
function editcontact:
public function editContact(array $data) { if(!empty($data)) { if($this->update($data, array('idContact = ?' => $data['idContact'])) > 0 ) { return true; } return false; } return false; }
et dans le .phtml:
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 31 32 33 34 35 36
| $('#editContact').submit(function(event)
{
var formId = $(this).attr('id');
// Stop full page load
event.preventDefault();
//Request
var data = {
// contact's properties
firstname : $("#firstname").val(),
lastname : $("#lastname").val(),
emailnotification : $("#emailnotification").val(),
batnotification : $("#batnotification").val()
};
// Send
$.ajax({
url: $('#'+formId).attr('action'),
dataType: 'json',
type: 'POST',
data: data,
success: function(data, textStatus, XMLHttpRequest)
{
if (data.response == true)
{
alert(data.message);
//upContent('userManagement/index/','');
}
else
{
alert(data.message);
} |
quand je cliquer sur update not se passe rien et je consulter la base pas fait la mise à jour merci de vous aider
Partager