Hello,
I have a ProfilesController that got an action "view" and a
ShoutsController that got the actions "index" and "shouts"
// In ProfilesController
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Profile.', true));
$this->redirect(array('action'=>'index'));
}
$this->set('profile', $this->Profile->read(null, $id));
$this->set('shouts', $this->requestAction(
array('controller' => 'shouts', 'action' => 'index'),
array('return', 'pass' => array($id))));
$this->set('shoutbox', $this->requestAction(
array('controller' => 'shouts', 'action' => 'shout_to'),
array('return', 'pass' => array($id))));
}
// in ShoutsController
function index($profileId = null) {
$this->Shouts->recursive = 0;
$this->paginate = array(
'fields' => array(
'Shout.id',
'Shout.created',
'Shout.body',
'Shout.is_hidden',
'Shout.is_deleted',
'Shout.is_deleted_by_shouter',
'Shout.from_profile_id',
'FromProfile.nickname',
),
'contain' => array(
'FromProfile',
),
'conditions' => array('Shout.profile_id' => $profileId),
'order' => 'created DESC',
'limit' => 1,
);
$this->set('shouts', $this->paginate());
}
function shout_to($toProfileId = null) {
if ($toProfileId != null and !empty($this->data)) {
$this->Shout->create();
$this->Shout->set(array(
'user_id' => $this->Auth->user('id'),
'profile_id' => $toProfileId,
'from_profile_id' =>
$this->Shout->Profile->getAuthedId($this-
>Auth->user())));
if ($this->Shout->save($this->data, true,
array('user_id', 'profile_id',
'from_profile_id', 'body'))) {
$this->Session->setFlash(__('The Shout has been
saved', true));
} else {
$this->Session->setFlash(__('The Shout could
not be saved. Please,
try again.', true));
}
}
if (isset($this->data['Shout']['has_shouted'])) {
$this->redirect(array('controller' => 'profiles',
'action' =>
'view', $toProfileId));
}
}
Now I have a question about passing forth and back information between
the "parent calling action" ProfilesController::view() and the
requested Actions.
Everything works for me but on the shoutbox requestAction:
- No form errors / validation errors displayed
- Entered form data not inserted on validation error
And on the shouts requestAction
- pagination options: <?=$form->create('Shout', array('action' =>
'shout_to', 'url' => $this->passedArgs))?>
Which logically is not added to behind as params to /profiles/view/5
Any ideas on either of these issues?
King regards
Jonas Hartmann
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---