Error: Call to a member function get() on a non-object
Bonjour tous,
j'ai un probléme que j'arrive pas à le résoudre. je suis en train d'ajouter (POST) des données dans ma BD. Donc j'ai developpé une foncion "AjouterActif()" dans la couche metier, voilà mon essai:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
class ActifsImpl extends Controller implements ActifsMetier
{
public function AjouterActif(Request $request){
$actif = new actifs();
$form = $this->createForm(new ActifsType(),$actif);
$form->submit($request->request->all());
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($actif);
$em->flush();
return $actif;
}else{
return $form;
}
}
} |
Voilà le code de mon controlleur:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
public function CreateActifAction(Request $request)
{
$objactif=$this->get('emtity_manager_actifs')->AjouterActif($request) ;
if(is_object($objactif))
{
return $this->redirect($this->generateUrl('Web_getUn_actifs', array('id' => $objactif->getIdactif())));
}
return $this->render('WebCIsBenchmarksActifsBundle:Default:index.html.twig',
array('listActifs' => $entities ,
'test' => '0',
//'form' => $form->createView()
)
);
} |
il affiche le message d'erreur suivant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| rror: Call to a member function get() on a non-object
500 Internal Server Error - FatalErrorException
//Stack Trace
//in vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php at line 250 -
*/
public function createForm($type, $data = null, array $options = array())
{
return $this->container->get('form.factory')->create($type, $data, $options);
}
/**
---
/*at Controller ->createForm () in src/CisBenchMarksBundle/Metier/ActifsImpl.php at line 51 -*/
public function AjouterActif(Request $request){
$actif = new actifs();
$form = $this->createForm(new ActifsType(),$actif); //ligne 51
$form->submit($request->request->all()); |
merci de m'aider pour résoudre ce probléme.