预览按钮显示数据库上的数据不仅仅是更新

时间:2018-02-15 09:53:28

标签: php symfony twig

当用户点击下一页时,每个页面的页面都有一个表格,我将数据保存在我的数据库中,直到第4页,当他点击验证时将数据保存在第四页上。 我在最后一页上创建了一个按钮预览(预览了4页的所有数据)

当用户想要更新最后一页上的表格时,当他点击预览时数据没有保存但我怎样才能显示刚刚进入但尚未保存的数据(即使我试图将它们保存在预测动作上但是同样的问题)?

存在按钮预览时表单的第四页(太长):

{{ form_start(form, {'attr':{'class': 'form-horizontal'}}) }}

<div class="form-group row">
    <label for="autresDistinctions" class="col-xs-3 col-sm-3 col-md-3 col-lg-3  form-control-label">Persons</label>
    <div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">
        {{ form_widget(form.persons, {'attr':{'class': 'form-control'}}) }}
    </div>
</div>

………..

<div class="form-group row">
    <div class="col-sm-offset-1 col-sm-11">

        <a href="{{ path('admin_Serv_ preview ') }}"><button type="button" class="btn btn-default">Preview</button></a>

        <button type="submit" class="btn btn-success" style="float: right">Validate</button>

    </div>
</div>
{{ form_end(form) }}

页面预览:

<div class="blog-header">
    <h1 class="blog-title">Preview </h1>
</div>
<div class="row">

div class="container fluid custom-locale-form">


    <div class="form-group row">
        <label for="nom" class="col-xs-3 col-sm-3 col-md-3 col-lg-3  form-control-label">Adrese</label>
        <div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">
            <span style="display:inline-block; width:500px;padding:5px">{{ ser.form.adress }}</span>
        </div>
    </div>

    <div class="form-group row">
        <label for="nom" class="col-xs-3 col-sm-3 col-md-3 col-lg-3  form-control-label">Phone</label>
        <div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">
            <span style="display:inline-block; width:300px;padding:5px">{{ ser.form.phone }}</span>
        </div>
    </div>

<div class="form-group row">
    <label for="nom" class="col-xs-3 col-sm-3 col-md-3 col-lg-3  form-control-label">F</label>
    <div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">
        <span style="display:inline-block; width:300px;padding:5px">{{ ser.form.fax }}</span>
    </div>
</div>
<div class="form-group row">
    <label for="nom" class="col-xs-3 col-sm-3 col-md-3 col-lg-3  form-control-label">E-mail</label>
    <div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">
        <span style="display:inline-block; width:300px;padding:5px">{{ ser.form.email }}</span>
    </div>
</div>

……………………………………

</div>
</div>

预览操作:

public function previewAction(Request $request)
{
    $ser = new Serv() :
    $forma = $ser->getFormulaire();
    $form = $this->createForm('StoreBundle\Form\FormPerType',$ forma);

    if(!$ser){
        return $this->redirectToRoute('Admin_ser_per');
    }

    $form ->handleRequest($request);


        $em = $this->getDoctrine()->getManager();
        $em->flush();




    return $this->render('AdminBundle:Serv:preview.html.twig', array(
        ‘ser’=> $ser,
        'form'   => $form->createView()

    ));
}

1 个答案:

答案 0 :(得分:0)

有两种方式 -

  1. 将数据存储在Cookie
  2. 将数据存储在数据库的临时表中,当您单击预览按钮时,获取数据并填充预览。