Neither the property..exist and have public access in class "Symfony\Component\Form\FormView".
Bonjour à tous,
J'ai eu une erreur comme celle-ci:
Citation:
Neither the property "centreAppel" nor one of the methods "centreAppel()", "getcentreAppel()"/"iscentreAppel()"/"hascentreAppel()" or "__call()" exist and have public access in class "Symfony\Component\Form\FormView".
mon controlleur :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| <?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use App\Entity\VicidialUserGroups;
use App\Entity\CallCenterGroups;
use App\Form\VicidialUserGroupsType;
use App\Form\CallCenterGroupsType;
class GroupeController extends AbstractController
{
/**
* @Route("/groupe", name="groupe")
*/
public function index(Request $request): Response
{
$groupe = new VicidialUserGroups();
$cappelgrp = new CallCenterGroups();
$form = $this->createForm(VicidialUserGroupsType::class, $groupe);
$form_assignment = $this->createForm(CallCenterGroupsType::class, $cappelgrp);
$em = $this->getDoctrine()->getManager();
$form->handleRequest($request);
$form_assignment->handleRequest($request);
if ($form->isSubmitted() && $form->isValid() || $form_assignment->isSubmitted() && $form_assignment->isValid){
$em->persist($groupe);
$em->persist($cappelgrp);
$em->flush();
}
return $this->render('groupe/nouveau_groupe.html.twig', array('form' => $form->createView() , 'form_assignment' =>$form->createView() ));
}
} |
Mon entité CallCenterGroups:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| <?php
namespace App\Entity;
use App\Repository\CallCenterGroupsRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CallCenterGroupsRepository::class)
*/
class CallCenterGroups
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=20)
*/
private $UserGroup;
/**
* @ORM\ManyToOne(targetEntity=CentreAppel::class, inversedBy="groupes")
* @ORM\JoinColumn(nullable=false)
*/
private $centreAppel;
public function getId(): ?int
{
return $this->id;
}
public function getUserGroup(): ?string
{
return $this->UserGroup;
}
public function setUserGroup(string $UserGroup): self
{
$this->UserGroup = $UserGroup;
return $this;
}
public function getCentreAppel(): ?CentreAppel
{
return $this->centreAppel;
}
public function setCentreAppel(?CentreAppel $centreAppel): self
{
$this->centreAppel = $centreAppel;
return $this;
}
} |
mon entité centre appel :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
| <?php
namespace App\Entity;
use App\Repository\CentreAppelRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CentreAppelRepository::class)
*/
class CentreAppel
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=10)
*/
private $triptyque;
/**
* @ORM\OneToMany(targetEntity=CallCenterGroups::class, mappedBy="centreAppel")
*/
private $groupes;
public function __construct()
{
$this->groupes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getTriptyque(): ?string
{
return $this->triptyque;
}
public function setTriptyque(string $triptyque): self
{
$this->triptyque = $triptyque;
return $this;
}
/**
* @return Collection|CallCenterGroups[]
*/
public function getGroupes(): Collection
{
return $this->groupes;
}
public function addGroupe(CallCenterGroups $groupe): self
{
if (!$this->groupes->contains($groupe)) {
$this->groupes[] = $groupe;
$groupe->setCentreAppel($this);
}
return $this;
}
public function removeGroupe(CallCenterGroups $groupe): self
{
if ($this->groupes->removeElement($groupe)) {
// set the owning side to null (unless already changed)
if ($groupe->getCentreAppel() === $this) {
$groupe->setCentreAppel(null);
}
}
return $this;
}
} |
mon formulaire :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <?php
namespace App\Form;
use App\Entity\CallCenterGroups;
use App\Entity\CentreAppel;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class CallCenterGroupsType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('centreAppel', EntityType::class, array('label' => 'Centre d\'appel', 'class' => CentreAppel::class, 'choice_label' => 'name',
'placeholder' => 'Choisissez un call center', 'attr' => array('class' => 'form-control')))
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => CallCenterGroups::class,
]);
}
} |
code twig ou l'erreur existe :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| {% extends 'base.html.twig' %}
{% block body %}
{{ form_start(form)}}
<div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
{% if form_assignment.centreAppel %}
<label>{{ form_label(form_assignment.centreAppel) }}</label>
{{ form_widget(form_assignment.centreAppel) }}
<span class="text-danger">{{ form_errors(form_assignment.centreAppel) }}</span>
{% endif %}
</div>
<div class="form-group">
<label>{{ form_label(form.userGroup) }}</label>
{{ form_widget(form.userGroup) }}
<span class="text-danger">{{ form_errors(form.userGroup) }}</span>
<div id="notification"></div>
</div>
</div>
<div class="form-group">
<label>{{ form_label(form.groupName) }}</label>
{{ form_widget(form.groupName) }}
<span class="text-danger">{{ form_errors(form.groupName) }}</span>
</div>
</div>
</div>
</div>
<div>
<button type="submit" class="btn btn-primary">Ajouter</button>
<a class="btn btn-warning" href="">Retour</a>
</div>
{{ form_end(form)}}
{% endblock %} |
en effet j'ai 2 forms à manipuler le prémier form : le premier affiche id groupe , , nom de groupe et la 2éme doit afficher les noms centres d'appel à fin d'affecter un centre d'appel à un groupe
comment je peux résoudre cette éreur
merci d'avance