Reputation: 2014
I use symfony 1.4.11 with Doctrine. I have private messages in my site, And I want to make possibility , that user can "reply" for a message. I try change "edit" method, but I do not now is this a good idea. How to make it?Now I have
$this->forward404Unless(
$messages = Doctrine_Core::getTable('Messages')->find(array($request->getParameter('id'))),
sprintf('Object messages does not exist (%s).', $request->getParameter('id'))
);
$messages->setMessage('') ;
$messages->setTitle('Re:'.$messages->getTitle()) ;
$messages->setRecipientId($messages->getSenderId()) ;
$this->form = new MessagesForm($messages);
But it do not create new message , it only edit...
Upvotes: 0
Views: 235
Reputation: 10413
Add a reply action:
public function executeReply(sfWebRequest $request)
{
$originalMessage = Doctrine_Core::getTable('Messages')->find(array($request['id']));
$this->forward404Unless($originalMessage, sprintf('Object messages does not exist (%s).', $request['id']));
$reply = new Message();
$reply->setTitle('Re:'.$originalMessage->getTitle());
$reply->setRecipientId($originalMessage->getSenderId());
$this->form = new MessagesForm($reply);
}
Additional notes:
copy
method on Doctrine_Record
instead of making a new one.Upvotes: 3
Reputation: 931
Maybe you have to design a self referenced table message : a reply is a new message which refer to the previous.
Upvotes: 1