从列

时间:2017-02-20 13:03:17

标签: php mysql model-view-controller symfony

我正在尝试解决我的symfony项目中的问题。我希望用户从列(完成)中的下拉列表中选择一个值,然后更新数据库中的新值。问题是,当我点击更新值时,它获取旧值并且不更新。这是PHP代码

/**
 * @Route("/pedidoventa/edit/{id}", name="pventa_edit")
 */
public function editpventaAction($id, Request $request)
{
    $Pedido_Venta = $this->getDoctrine()
        ->getRepository('AppBundle:Pedido_Venta')
        ->find($id);


    $Pedido_Venta->setEstado($Pedido_Venta->getEstado());


        //traer los datos

        $estado = ($Pedido_Venta->getEstado());


        $em = $this->getDoctrine()->getManager();
        $Pedido_Venta = $em->getRepository('AppBundle:Pedido_Venta')->find($id);

        $Pedido_Venta->setEstado($estado);


        $em->flush();

        $this->addFlash(
            'notificacion',
            'Estado Editado'
        );

        return $this->redirectToRoute('pventa_list');
    }

这是HTML表格

{% extends 'base.html.twig' %}

{% block body %}
    <h2 class="page-header">Pedidos de Venta</h2>
    <table class="table table-striped">
    <thead>
    <tr>
    <th>#</th>
    <th>Fecha - Hora</th>
    <th>Estado</th>
    <th>Total</th>
    </tr>
    </thead>
    <tbody>
    {% for Pedido_Venta in pedidosventa %}
    <tr>
    <th scope="row">{{Pedido_Venta.id}}</th>
    <td><a href="/pedidoventa/details/{{Pedido_Venta.id}}">{{Pedido_Venta.fecha}}</a></td>
    <td><select>
            <option selected="selected">{{Pedido_Venta.estado}}</option>
            <option>Listo</option>
            <option>Con Demora</option>
        </select>
    </td>
    <td></td>
    <td>
    <a href="/pedidoventa/edit/{{Pedido_Venta.id}}" class="btn btn-info">Editar</a>
    <a href="/pedidoventa/delete/{{Pedido_Venta.id}}" class="btn btn-danger">Eliminar</a>
    </td>
    </tr>
    {% endfor %}
    </tbody>
    </table>
    <a href="/pedidoventa/create" class="btn btn-primary">Nuevo Pedido de Venta</a>
{% endblock %}

任何帮助都会非常感激

1 个答案:

答案 0 :(得分:2)

您只发送身份证件。查看您的HTML,没有任何<form>标记,它正在等待您的下拉列表中的参数。请创建表单来处理您的问题。

相关问题