remove delete action and form

This commit is contained in:
Julien Fastré 2015-11-07 09:56:28 +01:00
parent 45d34dc312
commit 41c47df0c3

View File

@ -175,12 +175,10 @@ class CustomFieldsGroupController extends Controller
}
$editForm = $this->createEditForm($entity);
$deleteForm = $this->createDeleteForm($id);
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
@ -246,7 +244,6 @@ class CustomFieldsGroupController extends Controller
throw $this->createNotFoundException('Unable to find CustomFieldsGroup entity.');
}
$deleteForm = $this->createDeleteForm($id);
$editForm = $this->createEditForm($entity);
$editForm->handleRequest($request);
@ -259,49 +256,9 @@ class CustomFieldsGroupController extends Controller
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
/**
* Deletes a CustomFieldsGroup entity.
*
*/
public function deleteAction(Request $request, $id)
{
$form = $this->createDeleteForm($id);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find CustomFieldsGroup entity.');
}
$em->remove($entity);
$em->flush();
}
return $this->redirect($this->generateUrl('customfieldsgroup'));
}
/**
* Creates a form to delete a CustomFieldsGroup entity by id.
*
* @param mixed $id The entity id
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm($id)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('customfieldsgroup_delete', array('id' => $id)))
->setMethod('DELETE')
->add('submit', 'submit', array('label' => 'Delete'))
->getForm()
;
}
/**
* This function render the customFieldsGroup as a form.
@ -341,7 +298,7 @@ class CustomFieldsGroupController extends Controller
}
var_dump($form->getData());
var_dump(json_encode($form->getData()));
var_dump(json_enccode($form->getData()));
}