I dont know why this particular bit of code is simply not updating despite using this style of coding elsewhere succesfully.No exception is being thrown.
CREATE TABLE `accounts` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`accounts_username` varchar(60) DEFAULT NULL,
`accounts_fullname` varchar(600) DEFAULT NULL,
`accounts_email` varchar(600) DEFAULT NULL,
`accounts_password` varchar(600) DEFAULT NULL,
`accounts_status` varchar(600) DEFAULT NULL,
`accounts_roles` varchar(600) DEFAULT NULL,
`accounts_comments` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
In my form I have the code
public function __construct($options = null)
{
parent::__construct($options);
$optionsrole = array(
'guest' => 'guest',
'user' => 'user',
'writer' => 'writer',
'admin' => 'admin'
);
$optionsstatus = array(
'active' => 'active',
'pending' => 'pending'
);
$this->setName('account');
$id = new Zend_Form_Element_Hidden('id');
$username = new Zend_Form_Element_Text('accounts_username');
$username->setLabel('Username')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$fullname = new Zend_Form_Element_Text('accounts_fullname');
$fullname->setLabel('Fullname')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$email = new Zend_Form_Element_Text('accounts_email');
$email->setLabel('Email')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty')
->addValidator(new Zend_Validate_EmailAddress());
$password = new Zend_Form_Element_Password('accounts_password');
$password->setLabel('Password')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$status = new Zend_Form_Element_Select('accounts_status');
$status->setLabel('Status')
->setRequired(true)
//->addMultiOptions(array('Active','Pending'));
->addMultiOptions($optionsstatus);
$role = new Zend_Form_Element_Select('accounts_roles');
$role->setLabel('Role')
->setRequired(true)
//->addMultiOptions(array('guest','user','writer','admin'));
->addMultiOptions($optionsrole);
$comments = new Zend_Form_Element_Textarea('accounts_comments');
$comments->setLabel('Comments')
//->setAttrib('size',200)
->setAttrib('rows',20)
->setAttrib('cols',50);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$this->addElements(array($id, $username, $fullname,$email,
$password,$status,$role,$comments,$submit));
}
In my accounts controller
public function editAction()
{
$this->view->title = "Edit User Account";
$this->view->headTitle($this->view->title, 'PREPEND');
$form = new Form_Account();
$form->submit->setLabel('Save');
$accounts = new Model_DbTable_Account();
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
/*
if($accounts->checkUnique($formData['accounts_username'])){
$this->view->errorMessage = "Username already taken. Please choose another one.";
return;
}
*/
$id = (int)$form->getValue('id');
$username = $form->getValue('accounts_username');
$fullname = $form->getValue('accounts_fullname');
$email = $form->getValue('accounts_email');
$password = $form->getValue('accounts_password');
$status = $form->getValue('accounts_status');
$roles = $form->getValue('accounts_roles');
$comments = $form->getValue('accounts_comments');
//$accounts = new Model_DbTable_Account();
$accounts->updateaccount($username, $fullname,$email,
$password,$status,$roles,$comments);
$this->_redirect('/account');
} else {
$form->populate($formData);
}
} else {
$id = $this->_getParam('id', 0);
if ($id > 0) {
$account = new Model_DbTable_Account();
$form->populate($account->getaccount($id));
}
}
}
In my model
public function updateaccount($id,$username, $fullname, $email,
$password,$status,$roles,$comments)
{
$data = array(
'accounts_username' => $username,
'accounts_fullname' => $fullname,
'accounts_email' => $email,
'accounts_password' => md5($password),
'accounts_status' => $status,
'accounts_roles' => $roles,
'accounts_comments' => $comments,
);
$this->update($data, 'id = '. (int)$id);
}
Am i missing something?