i'm trying to get data from the database and pas it to the form's drop down list
this is the Entity from where i'm looking to get the data from, specifically the type column
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="AppBundle\Repository\TypesRepository")
* @ORM\Table(name="types")
*/
class Types
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(name="idtype",type="integer")
*/
private $idtype;
/**
* @ORM\Column(type="string", length=100)
*/
private $type;
and this is the type class that holds the form,as you can see i created a construct based on some internet cherche that i have done, the constructer adds the passed value to the variable, then it's called in the EntityType
class sell_form extends AbstractType
{
protected $cat;
public function __construct (Types $cat)
{
$this->cat = $cat;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('categorie',EntityType::class,array(
"required"=>false,
'class' => 'AppBundle\Entity\Types',
'choices' => $cat
))
;
;
}
}
and finaly this is the controller where i inisialize the $cat variable from the database using a repository function
/**
* @Route("/Old/buy", name="old_buy")
*/
public function Old_buyAction()
{
return $this->render('/user_module/Old Views/Old_buy.html.twig');
}
/**
* @Route("/Old/sell", name="old_sell")
*@Method({"GET","POST"})
*/
public function Old_sellAction()
{
$cat = $this->getDoctrine()->getManager()->getRepository('AppBundle:Types')-
>tn();
/*line 122 */
$form = $this->createForm(new sell_form($cat));
//$form = $this->createForm(sell_form::class,$cat);
return $this->render("user_module/Old Views/old_sell.html.twig",array(
"myForm"=> $form->createView(),
));
this is the error that it's shown
Catchable Fatal Error: Argument 1 passed to
AppBundle\Forms\sell_form::__construct() must be an instance of
AppBundle\Entity\Types, array given, called in
C...\OldController.php
on line 122 and defined`
Many Thanks in advance