Hi Bernard,

There are many ways to skin a cat...

if you look at the Blog tutorial in the manual, there is the add()
function:

    function add()
    {
        if (!empty($this->data))
        {
            if ($this->Post->save($this->data))
            {
                $this->flash('Your post has been saved.','/posts');
            }
        }
    }

This is called initially with no params set.  This will fail the
(!empty($this->data) ) condition and render the view add.thtml (the
name of the function).  The user fills in the form and presses submit.
The form in this case will post back to the same function, but this
time the form will be populated with data.  The data will be saved (if
valid) and the flash statement redirects back to the index() page.

If you copy this functionality then you would not have 2 different
functions in the controller with the same view, only one.

If you didn't want the if() statement, you could post back to a
different function, eg. save( ) .  This could redirect on the flash
statement again, if valid.  If it fails validation then you could
render('add') which will force the add.thtml to be redisplayed, instead
of the default save.thtml (which does not exist).

Hope this helps


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

Reply via email to