Ok, that seems to have it working. Thanks for all the replies to get this resolved!
Ronan
On Tuesday, July 17, 2012 1:27:15 PM UTC+2, AD7six wrote:
-- On Tuesday, July 17, 2012 1:27:15 PM UTC+2, AD7six wrote:
On Wednesday, 11 July 2012 15:20:21 UTC+2, Banana Man wrote:Hi,I am trying to setup an Edit User authentication action. I have authentication working fine for adding a user but when i try to edit a user i am running into a problem.If i try to edit a user when all information supplied passes validation it works fine (URL: http://localhost/users/edit/3). If however i leave a textfield blank when i am validating it against 'notEmpty' the first time i hit the form submit button it works as expected and reloads the edit user page with the validation error displayed (URL: http://localhost/users/edit/3) . If i do nothing and try to submit the form again with the blank textfield i now get redirected to http://localhost/users/edit with an Invalid User message "Error: The requested address '/users/edit' was not found on this server." <!-- app/Controller/UsersController.php --> public function edit($id = null) {$this->User->id = $id;if (!$this->User->exists()) {throw new NotFoundException(__('Invalid user'));}if ($this->request->is('post') || $this->request->is('put')) {if ($this->User->save($this->request->data)) { $this->Session->setFlash(__('The user has been saved')); $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The user could not be saved. Please, try again.')); }} else {$this->request->data = $this->User->read(null, $id);}}<!-- view/users/edit.ctp --><div class="users form"><?php echo $this->Form->create('User', array('action' => 'edit'));?>If you are using cake 2.x just use<?php echo $this->Form->create('User');?>You are forcing the target for the form to /foo/edit instead of taking the default value (which is the current url).AD
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment