Hi all,

This is doing my head in so I'm posting here as a last resort. I'm
reasonably new to cakephp, I've written a simple CMS app last year but
I'm working on a new v1.2.0.6311 project now with user management/acl
built in. Basically I'm working on the user management area at the
moment specifically a reset password function. Now it's not practical
to have the password field in the "edit user" form because it's not
something I wan't admins to accidentally change. So I've got the edit
user form setup with an ajax link to the reset password action. The
ajax link in the edit form looks like this:

echo $ajax->link('Reset Password', '/users/resetPassword/'.$form-
>value('User.id'), array('update' => 'ResetPassword'), null, FALSE);

So when I click on that the "ResetPassword" div is updated with the
reset_password.ctp view which looks like this:
<?php echo $ajax->form(array('action' => '/users/resetPassword'),
'post', array('update' => 'resetPassword'));?>
        <fieldset>
                <legend>Reset Password</legend>
        <?php
                echo $form->hidden('username');
                echo $form->input('password', array('type' => 'password', 
'value' =>
''));
        ?>
        </fieldset>
<?php echo $ajax->submit('Reset Password', array('url'=>'/users/
resetPassword')); ?>

So I enter a new password and hit "Reset Password"... ... ...
nothing.

The resetPassword section of my users controller looks like this:

function resetPassword($id = null) {
        if (!$id && empty($this->data)) {
                $this->Session->setFlash('Invalid User');
                $this->redirect(array('action'=>'index'), null, true);
        }
        if (!empty($this->data)) {
                $this->cleanUpFields();
                if ($this->User->save($this->data))
           {
               $this->Session->setFlash('The password has been
reset');
                } else {
                        $this->Session->setFlash('The password could not be 
reset. Please,
try again.');
                }
        }
        if (empty($this->data))
      {
                $this->data = $this->User->read(null, $id);
        }
}

The top of my users controller looks like this:
var $name       = 'Users';
var $helpers    = array('Html', 'Form', 'Javascript', 'Ajax');
var $components = array('InheritAcl', 'RequestHandler');

Any ideas where I'm going wrong here? I'm really having difficulty
finding any simple ajax form tutorials for v1.2. The form works
perfectly without ajax.

FYI firebug reports an error in prototype.js on line 2239
"element has no properties"
_observeAndCache(null, "submit", function(), false)prototype.js (line
2239)
observe(null, "submit", function(), false)prototype.js (line 2266)
evalScripts("\n//<![CDATA[\nEvent.observe('form19482', 'submit',
function(event) { new Ajax.Updater('resetPassword'...")prototype.js
(line 212)
collect("\n//<![CDATA[\nEvent.observe('form19482', 'submit',
function(event) { new Ajax.Updater('resetPassword'...", 0)prototype.js
(line 367)
(no name)("\n//<![CDATA[\nEvent.observe('form19482', 'submit',
function(event) { new Ajax.Updater('resetPassword'...")prototype.js
(line 328)
_each(function())prototype.js (line 541)
each(function())prototype.js (line 326)
collect(function())prototype.js (line 366)
evalScripts()prototype.js (line 212)
(no name)()

TIA.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to