Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Bonjour ,
j'ai un souci avec checkbox quand je décocher ne fait pas la mise à jour de champ de la table de la base de donnée voilà mon code :
$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 :
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:
$('#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
Hors ligne