Hy,
I'm using jq_link_to_remote function to load in a div a form to do answers to a comment (like in facebook). My problem is that i call this form like that 'social/respond/id/14' where id content the parent opinion. I create a funcion that setValue to a hidden field in my form.
Then, why if i try to call directly 'social/respond/id/14' it assign correctly value and whe开发者_运维知识库n i do it with jq_link call not? I do a 'echo' of value passed as input in function than set value of field and it works fine.
Thanks.
Form code..
public function setDefaultEntityId($id_response=0)
{
if($id_response!=0){
$this->setDefault('sf_opinion_id',$id_response);
}
$this->configure();
}
template opinions
<?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')
); ?>
action responder
$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();
}
}
And finally, an example of generated code...
<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>
I hope that helps... :)
Hmm, it looks clean - I'm not sure what the problem is. However, I'm not sure why you do this in the form:
if($id!=0){
$this->setDefault('id_elemento',$id);
}
if($id_response!=0){
$this->setDefault('id_elemento',$id_response);
}
you are setting the default for id_elemento twice - if $id and $id_response are not 0, then id_elemento gets set to $id first, then $id_response... which doesn't sound right.
精彩评论