473,503 Members | 11,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Issue with checkbox on zend framework 1

132 New Member
I have an issue with a checkbox: it does not update to the database.
Expand|Select|Wrap|Line Numbers
  1. $emailnotification = new Zend_Form_Element_Checkbox('emailnotification ', 'emailnotification', array(
  2.     'checkedValue'  => 1,
  3.     'uncheckedValue' => 0,
  4. ) );
  5. $emailnotification->setLabel('emailnotification');
  6. $emailnotification->setValue(1);
  7. $this->addElement($emailnotification);
and on Controller I have action update the following code below for update:
Expand|Select|Wrap|Line Numbers
  1. if($this->_request->isPost())
  2. {
  3.     $formData = $this->getRequest()->getPost();
  4.     if($form->isValid($formData))
  5.     {
  6.         $contact = new Admin_Model_DbTable_Contact();
  7.         $data = array();
  8.         $data['idContact']            = $idContact;
  9.         $data['firstname']            = $form->getValue('firstname');
  10.         $data['lastname']             = $form->getValue('lastname');
  11.         $data['emailnotification']    = $form->getValue('emailnotification');
  12.         if($contact->editContact($data))
  13.         {
  14.             echo json_encode(array(
  15.                 "response"   => true,
  16.                 "message"    => "Contact " . $data['firstname'] . " " . $data['lastname'] . "a été modifié"
  17.             ));
  18.             exit();
  19.         } else {
  20.             echo json_encode(array(
  21.                 "response"     => false,
  22.                 "errorMessage" => "Il y a eu une erreur dans l'edition de Contact."
  23.             ) );
  24.             exit();
  25.         }
  26.     }
  27. }
function editcontact:
Expand|Select|Wrap|Line Numbers
  1. public function editContact(array $data) { if(!empty($data)) { if($this->update($data, array('idContact = ?' => $data['idContact'])) > 0 ) { return true; } return false; } return false; }
on .phtml
Expand|Select|Wrap|Line Numbers
  1. $('#editContact').submit(function(event)
  2. {
  3.     var formId = $(this).attr('id');
  4.     // Stop full page load
  5.     event.preventDefault();
  6.  
  7.     //Request
  8.     var data = {
  9.         // contact's properties 
  10.         firstname               :       $("#firstname").val(),
  11.         lastname                :       $("#lastname").val(),
  12.         emailnotification       :       $("#emailnotification").val(),
  13.         batnotification         :       $("#batnotification").val()
  14.  
  15.     };  
  16.  
  17.     // Send
  18.     $.ajax({
  19.         url: $('#'+formId).attr('action'),
  20.         dataType: 'json',
  21.         type: 'POST',
  22.         data: data,
  23.         success: function(data, textStatus, XMLHttpRequest)
  24.         {                    
  25.             if (data.response == true)
  26.             {
  27.                 alert(data.message);
  28.                 //upContent('userManagement/index/','');
  29.  
  30.  
  31.  
  32.             }
  33.             else
  34.             { 
  35.                 alert(data.message);
  36.             }
and not worked for me always message Undefined and not update the data base

Thanks in advance
May 2 '15 #1
0 1235

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3220
by: R. Rajesh Jeba Anbiah | last post by:
The Zend framework preview release is out <http://framework.zend.com/> and I don't know why such PEAR like (yet another) framework is needed. At the same time, Rasmus' article...
1
1669
by: pjSoni | last post by:
Hi I would like to know from where to start learning zend frame work I need to develop project based on zend framework so what tools of zend framework I should use like db, template handling...
4
4444
by: chonny | last post by:
How to connect and query odbc database with zend framework db?
0
1594
by: hzqij1978 | last post by:
I am a newer of Zend Framework, i write a program to test the speed of Zend Framework, code like this: /var/www/htdocs/index.php <?php require_once 'Zend.php'; require_once...
1
1593
by: enkara | last post by:
Hi!! I'm trying to embebe an event calendar on my website but I'm usign Zend Framework and I don't know how to do it. It seems like Zend Framework doesn't accept third party tools. I don't know...
5
1488
by: Sanders Kaufman | last post by:
I've been programming a long time, but I'm not very bright these days. I've been using Zend Studio for a couple of years (LOVING IT!!) to build a web framework. I've been *hearing* about a...
3
3224
by: Peter Wang | last post by:
Hi, all. I recently encountered a very annoying problem while using Zend Framework(ZF). We use ZF in our web application, and it works fine at the beginning, but later when concurrent...
0
4938
by: Sean Quinn | last post by:
Hi All, First off let me say that from what I've seen of the XDebug debugger, I'm pretty impressed--it would just be nice if I could actually use it to its full potential in Eclipse. My...
0
1930
by: Mike Miller | last post by:
Am using php 5.2.6 and Zend Framework. The Zend Framework provides a bunch of API's (i.e. PDO_MSSQL) for connecting to and dealing with databases. What I am finding is that PDO_MSSQL will not...
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.