dongxing2015 2016-08-08 06:26
浏览 32
已采纳

将id传递给modals symfony 2.3

Is there any way to pass id's to modals in symfony 2.3?

here's an example:

<a href="{{ path('route', {'id':table.id}) }}" data-reveal-id = "modal" class = "icon" etc.>

so first, without the data reveal the icon becomes a link that when clicked, it goes to the action in the route. That's fine since it's working.

<div id="modal" class="reveal-modal large">
    <input type="password" id="someid"/>

In my modal I have a password input type, I have a jquery that submits this form, my problem is that this time the code doesn't go to the route.

Anyone with answers will be greatly praised. I swear you won't hear me but I WILL be praising you, thanks in advance.

P.S. I'm fairly new to symfony and the 2.3 documentation just vanished from the site so i'm not sure where to get the info I need other than here.

  • 写回答

1条回答 默认 最新

  • douxianwu2221 2016-08-08 08:23
    关注

    Set the form 'action' attribute with setAction, when you create your form :

    $form = $this->createFormBuilder($entity)
    ->setAction($this->generateUrl('route',array('id'=>$table->getId())))
    ->setMethod('GET')
    ->add('name', 'text')
    ->getForm();
    

    or

    $form = $this->createForm(
        'my_form_type',
         $entity,
         array('action'=>$this->generateUrl('route',array('id'=>$table->getId()))
    ));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?