El 13/06/2007, a las 2:15, Geoff Ford escribió:
> How are you building the form and how are you passing the data in?
I was building it relaying on $this->data (I'm very new to Cake, 2-3
weeks or so, and even more newbie to Ajax... 2-3 days or so).
> 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.
I think you point me to the solution. I rewrite the action in the
controller:
function add () {
if (!empty ($this->data['Frasecita'])) {
if ($this->Frasecita->save($this->data)) {
$this->Frasecita->create ();
// Clear $this->data to get an empty form ->
Thanks Geoff Ford
$this->data = array ();
}
}
// If Ajax Retrieve data to show the index table and redraw the
entire view (todo.ctp).
if ($this->RequestHandler->isAjax()) {
$this->set ('frases', $this->Paginate ());
$this->render ('todo');
}
// Else render the default view for this action
}
Simply clear the $this->data after saving.
The point is that the view is going to render the form in the same
cycle, so $this->data is still populated with POST data.
Thank you.
--
Fran Iglesias
[EMAIL PROTECTED]
http://cakephilia.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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---