Hello!
I'am new to Cake and - call me stupid - got some problems
understanding, how to call different actions from the same controller
at one page e.g. a form that submits data to the model and a table
which shows the results of this (or another) model at the same page.
Or as real world example, a blog, which shows a list of comments, a
comment-form and all validation error messages at the same page.
By now, I don't have a clue, how to handle this or even more complex
layouts with more forms and tables.
Maybe something like this:
<?php
class BlogController extends AppController {
var $uses = array('Post');
function index() {
$this->set("form1",$this->add());
$this->set("list1",$this->listcomments();
}
function listComments() {
// logic for reading comments
}
function add ()
{
if (empty($this->data))
{
$this->render();
}
else
{
if($this->Post->save($this->data))
{
//ok cool, the stuff is valid
}
else
{
//Danger, Will Robinson. Validation errors.
$this->set('errorMessage', 'Please correct errors
below.');
$this->render();
}
}
}
}
?>
Thank you, for helping a noob ...
MaDo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---