0
幾乎整個晚上我試圖更新的模式形式的實體,但它不工作的...Symfony2的更新實體進行模態
我的樹枝模板的樣子:
{% for entity in entities %}
<tr>
<td class="text-center">{{ entity.id }}</td>
<td class="text-center">{{ entity.cashbackDays }} Tage</td>
<td class="text-center">{{ entity.cashbackPercent }} %</td>
<td class="text-center">{{ entity.nettoDays }} Tage</td>
<td class="text-center">
<a data-toggle="modal" data-target="#editCashbackModal" class="btn btn-xs btn-default" href="{{ path('cashback_edit', { 'id': entity.id }) }}"><i
class="fa fa-edit"></i></a>
</td>
</tr>
{% endfor %}
</tbody>
<div class="modal fade" id="editCashBackModal" tabindex="-1" role="dialog" aria-labelledby="editCashBackModalLabel" aria-hidden="true">
</div>
模態模板的樣子:
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h4 class="modal-title" id="editCashBackModalLabel">Skontoschlüssel bearbeiten</h4>
</div>
<div class="modal-body">
{{ form(edit_form) }}
<ul class="record_actions">
<li>
<a href="{{ path('cashback') }}">
Back to the list
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
</div>
<div class="modal-footer">
</div>
</div>
</div>
我想我在URL中的變量問題,但我不知道如何解決它。
這是我的控制器的一部分:
public function editAction($id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('sulzerAppBundle:Cashback')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Cashback entity.');
}
$editForm = $this->createEditForm($entity);
$deleteForm = $this->createDeleteForm($id);
return array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
/**
* Creates a form to edit a Cashback entity.
*
* @param Cashback $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createEditForm(Cashback $entity)
{
$form = $this->createForm(new CashbackType(), $entity, array(
'action' => $this->generateUrl('cashback_update', array('id' => $entity->getId())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
}
的錯誤是,模式不以點擊編輯
什麼是錯誤? – ihsan