How are you building the form and how are you passing the data in?

If you are unsing the formhelpers they rely on $this->data.  If in
your controller you are setting $this->data that is why the details
are being displayed in the form.

What I have done (not on ajax forms) is save the submitted $this->data
to a temp variable.  If the validateion fails I set $this->data to the
temp variable thus resetting the fields to waht they entered.  If the
validsation passes you can set $this->data to null to have an empty
form.

As mentioned - not tested on Ajax forms so YMMV

On Jun 13, 9:54 am, Fran Iglesias <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've been playing with the AjaxHelper (in Cake v 1.2.0.5146alpha).
>
> I'm having a problem trying to reset a form after submitting the data
> and saving them. This works well but I was unable to reset the form.
> I guess there is some persistence system that works even  between
> reloads of the page (good, but I don't know where).
>
> I've tried Form.reset() (from prototype.js) in the "complete"
> callback (AjaxHelper::submit). But nothing happens.
>
> I've tried other approaches with javascript with no result.
>
> Finally, I've set default values in the view (passing an array with
> 'value' => '' to FormHelper::input)
>
> This works well, except for the fact that if the user inputs wrong
> data and these doesn't validate, the form is resetted.
>
> So... the questions:
>
> Is there persistence support for data in forms (and where)? I think
> so, but...
> Is there a way to reset a form after submit with ajax?
>
> (Check in the controller or view if is necessary to reset the form???)
>
> Thanks in Advance.
>
> --
> Fran Iglesias
> [EMAIL PROTECTED]://cakephpilia.blogspot.com


--~--~---------~--~----~------------~-------~--~----~
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