やあ、
私はjq_link_to_remote関数を使用して、コメントへの回答を行うためのフォームをdivにロードしています(Facebookのように)。私の問題は、このフォームを「social / response / id / 14」のように呼んでいることです。ここで、idは親の意見を含んでいます。フォームの非表示フィールドにsetValueを設定する関数を作成します。
それでは、なぜ直接'social / reply / id / 14'を呼び出そうとすると、正しく値が割り当てられ、jq_linkで呼び出した場合は呼び出されないのですか?フィールドの設定値よりも関数の入力として渡された値の「エコー」を実行すると、正常に動作します。
ありがとう。
フォームコード。
public function setDefaultEntityId($id_response=0)
{
if($id_response!=0){
$this->setDefault('sf_opinion_id',$id_response);
}
$this->configure();
}
テンプレート意見
<?php echo jq_link_to_remote('opinar',
array(
'update' => 'respuesta_hidden_'.$opinion->getId(),
'url' => 'social/responder?id_response='.$opinion->getId()),array('rel' => 'nofollow','class' =>'mini')
); ?>
アクションレスポンダー
$this->form = new OpinionResForm();
$this->form->setDefaultEntityId($request->getParameter('id_response'));
// formulario opiniones
if($request->isMethod(sfRequest::POST))
{
$this->form->bind($request->getParameter($this->form->getName()));
if ($this->form->isValid()) {
$opinion = $this->form->save();
}
}
そして最後に、生成されたコードの例...
<a onclick="jQuery.ajax({type:'POST',dataType:'html',success:function(data, textStatus){jQuery('#respuesta_hidden_1').html(data);},url:'/sfproject/zampalo/web/frontend_dev.php/social/responder/id_response/1'}); return false;" href="#" class="mini" rel="nofollow">opinar</a>
それがお役に立てば幸いです...:)