Expand|Select|Wrap|Line Numbers
- $emailnotification = new Zend_Form_Element_Checkbox('emailnotification ', 'emailnotification', array(
- 'checkedValue' => 1,
- 'uncheckedValue' => 0,
- ) );
- $emailnotification->setLabel('emailnotification');
- $emailnotification->setValue(1);
- $this->addElement($emailnotification);
Expand|Select|Wrap|Line Numbers
- 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();
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- public function editContact(array $data) { if(!empty($data)) { if($this->update($data, array('idContact = ?' => $data['idContact'])) > 0 ) { return true; } return false; } return false; }
Expand|Select|Wrap|Line Numbers
- $('#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);
- }
Thanks in advance