Bonjour,
Voila je rencontre un petit problème avec mon code.
ceci le code d'erreur :
Neither the property "callcenterId" nor one of the methods "callcenterId()", "getcallcenterId()"/"iscallcenterId()"/"hascallcenterId()" or "__call()" exist and have public access in class "Symfony\Component\Form\FormView".
mon controlleur :
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\Entity\CallCenter;
use App\Form\VicidialUserGroupsType;
use App\Form\CallCenterGroupsType;
class GroupeController extends AbstractController
{
public function nouveauAction(Request $request): Response
{
$session = $request->getSession();
if ($session->get('niveau') !== 4){
throw $this->createAccessDeniedException();
}
$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){
$centreappel = $em->getRepository(CallCenter::class)->find($form->get('callcenterId')->getData());
$cappelgrp->setUserGroup($centreappel->getTriptyque() . '_' . $form->get('userGroup')->getData());
$groupe->setUserGroup($centreappel->getTriptyque() . '_' . $groupe->getUserGroup());
$groupe->setGroupName($centreappel->getTriptyque() . '_' . $groupe->getGroupName());
$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:
<?php
namespace App\Entity;
use App\Repository\CallCenterGroupsRepository;
use Doctrine\ORM\Mapping as ORM;
/**
@ORM\Table(name="call_center_groups")
*/
class CallCenterGroups
{
/**
/**
/**
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;
}
/**
@return CallCenterGroups
*/
public function setCallcenterId($callcenterId) {
$this->callcenterId = $callcenterId;
return $this;
}
/**
}
mon formulaire :
<?php
namespace App\Form;
use App\Entity\CallCenter;
use App\Entity\CallCenterGroups;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
class CallCenterGroupsType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('callcenterId', EntityType::class, array('label' => 'Centre d\'appel', 'class' => CallCenter::class, 'choice_label' => 'name',
'empty_data' => 'Choisissez un centre appel',
'required' => false,
'attr' => array('class' => 'form-control')))
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => CallCenterGroups::class,
]);
}
}
mon twig :
{% extends 'superadmin.html.twig'%}
{% block body %}
<div class="container-fluid">
<!-- Page Heading -->
<h1 class="h3 mb-4 text-gray-800">Nouveau groupe</h1>
</div>
<div>
<!-- form start -->
{{ form_start(form)}}
<div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
{% if form_assignment.callcenterId is defined %}
<label>{{ form_label(form_assignment.callcenterId) }}</label>
{{ form_widget(form_assignment.callcenterId) }}
<span class="text-danger">{{ form_errors(form_assignment.callcenterId) }}</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="col-md-6">
<div class="form-group">
<label>{{ form_label(form.allowedCampaigns) }}</label>
{{ form_widget(form.allowedCampaigns) }}
<span class="text-danger">{{ form_errors(form.allowedCampaigns) }}</span>
</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)}}
</div>
</div>
</div>
{% endblock %}
code d'entité callcenter :
<?php
namespace App\Entity;
use App\Repository\CallCenterRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CallCenterRepository::class)
*/
class CallCenter
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @ORM\Column(name="id", type="integer", nullable=false)
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=10)
*/
private $triptyque;
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;
}
public function __toString() {
return (string) $this->id;
}
}
comment je peux résoudre cette érreur
merci d'avance
Bonjour,
Malgré que le formatage de ton code soit illisible ... je pense comem ça qu'il doit te manquer tes getters et tes setters
bonjour , je modifie la poste
les getters et setters sont présentés
peut etre j'oublie de mettre une rélation entre les deux entités callcenter et callcentergroup puisque je veux affecter un centre appel a chaque groupe
merci pour votre réponse