jeudi 30 avril 2015

Issue with checkbox on zend framework 1

I have an issue with a checkbox: it does not update to the database.

$emailnotification = new Zend_Form_Element_Checkbox('emailnotification ', 'emailnotification', array(
    'checkedValue'  => 1,
    'uncheckedValue' => 0,
) );
$emailnotification->setLabel('emailnotification');
$emailnotification->setValue(1);
$this->addElement($emailnotification);

and on Controller i have action update the following code below for update :

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();

Thanks in advance




Aucun commentaire:

Enregistrer un commentaire