protected function processArticleForm(AddForm $form, Article $article) { $request = $this->getRequest(); $form->bind($article); if ($request->isPost()) { $actions = $request->getPost('actions'); // Process delete. if (!empty($actions['delete']) && $article->getId()) { return $this->redirect()->setBypassDestination(true)->toRoute('admin/article/delete', array('id' => $article->getId())); } $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); $form->setData($post); if ($form->isValid()) { $objectManager = $this->getObjectManager(); $objectManager->persist($article); $objectManager->flush(); } } }
public function init() { parent::init(); $this->get('actions')->get('submit')->setAttribute('value', $this->translate('Update')); $this->get('actions')->add(array('name' => 'delete', 'type' => 'submit', 'options' => array('disable_group_wrapper' => true), 'attributes' => array('value' => $this->translate('Delete'), 'class' => 'btn btn-danger'))); }