In my conversations view, I'm trying to make it so I can add messages to a conversation.
Currently I have a Conversation hasMany Messages relationship.
Now when I try to invoke the following code:
<?=$ajax->form('message','post',array('update'=>'messages')); ?>
It produces a form with a form action to
action="facebook/conversations/messages/add"
So I get an error saying I don't have the a controller function labeled "messages" in my conversat开发者_C百科ions controller.
I want the action to go to my messages controller instead.
I'm sure its some really silly code I have to implement, but I'd really appreciate your help.
You can pass a url explicitly when you create a form.
echo $ajax->form('message', 'post', array('url'=>$html->url(array('controller'=>'messages', 'action'=>'action_name'))));
From the CakePHP Book you can also use a slightly different variant of the Ajax form function and avoid using the Html Helper to build the url.
$this->Ajax->form( array(
'type' => 'post',
'options' => array(
'url' => array(
'controller' => 'messages',
'action' => 'action_name'
)
)
));
精彩评论