protected function handleForm(FormInterface $form, $successMessage, $itemToPersist = null)
    {
        if ($form->isValid()) {
            $documentManager = $this->get('object_manager');

            if ($itemToPersist) {
                $documentManager->persist($itemToPersist);
            }

            $documentManager->flush();

            $this->get('session')->getFlashBag()->add('success', $successMessage);

            return true;
        }

        return false;
    }
protected function handleForm(FormInterface $form, $successMessage, $itemToPersist = null)
    {
        if ($form->isValid()) {
            $documentManager = $this->get('object_manager');

            if ($itemToPersist) {
                $documentManager->persist($itemToPersist);
            }

            $documentManager->flush();

            $this->get('session')->getFlashBag()->add('success', $successMessage);

            return true;
        }

        return false;
    }
protected function handleForm ( FormInterface $ form , $ successMessage , $ itemToPersist = null ) { if ( $ form -> isValid ( ) ) { $ documentManager = $ this -> get ( 'object_manager' ) ; if ( $ itemToPersist ) { $ documentManager -> persist ( $ itemToPersist ) ; } $ documentManager -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , $ successMessage ) ; return true ; } return false ; }
Do some stuff if admin form is valid

@param FormInterface $form
@param string        $successMessage
@param mixed|null    $itemToPersist

@return bool
Do some stuff if admin form is valid