configure forms

This commit is contained in:
Simon Vieille 2022-03-06 19:57:48 +01:00
parent 6df0000382
commit 894c31f09c
6 changed files with 61 additions and 19 deletions

View file

@ -122,18 +122,16 @@ class InterventionAdminController extends CrudController
->setDefaultSort('index', 'date', 'desc') ->setDefaultSort('index', 'date', 'desc')
->setView('form', 'admin/intervention/_form.html.twig')
->setField('index', 'Establishment', Field\TextField::class, [ ->setField('index', 'Establishment', Field\TextField::class, [
'property' => 'establishment', 'property' => 'establishment',
'sort' => ['establishment', '.establishment'], 'sort' => ['establishment', '.establishment'],
]) ])
->setField('index', 'Speaker', Field\TextField::class, [
'property' => 'speaker',
'sort' => ['speaker', '.speaker'],
'attr' => ['class' => 'col-3,']
])
->setField('index', 'Date', Field\DateField::class, [ ->setField('index', 'Date', Field\DateField::class, [
'property' => 'date', 'property' => 'date',
'sort' => ['date', '.date'], 'sort' => ['date', '.date'],
'attr' => ['class' => 'col-3'],
]) ])
->setBatchAction('index', 'delete', 'Delete', function(EntityInterface $entity, EntityManager $manager) { ->setBatchAction('index', 'delete', 'Delete', function(EntityInterface $entity, EntityManager $manager) {

View file

@ -23,7 +23,7 @@ class Intervention implements EntityInterface
/** /**
* @ORM\ManyToMany(targetEntity=Speaker::class, inversedBy="interventions") * @ORM\ManyToMany(targetEntity=Speaker::class, inversedBy="interventions")
*/ */
private $speaker; private $speakers;
/** /**
* @ORM\ManyToOne(targetEntity=Establishment::class, inversedBy="interventions") * @ORM\ManyToOne(targetEntity=Establishment::class, inversedBy="interventions")
@ -82,7 +82,7 @@ class Intervention implements EntityInterface
public function __construct() public function __construct()
{ {
$this->speaker = new ArrayCollection(); $this->speakers = new ArrayCollection();
$this->tools = new ArrayCollection(); $this->tools = new ArrayCollection();
} }
@ -94,15 +94,15 @@ class Intervention implements EntityInterface
/** /**
* @return Collection<int, Speaker> * @return Collection<int, Speaker>
*/ */
public function getSpeaker(): Collection public function getSpeakers(): Collection
{ {
return $this->speaker; return $this->speakers;
} }
public function addSpeaker(Speaker $speaker): self public function addSpeaker(Speaker $speaker): self
{ {
if (!$this->speaker->contains($speaker)) { if (!$this->speakers->contains($speaker)) {
$this->speaker[] = $speaker; $this->speakers[] = $speaker;
} }
return $this; return $this;

View file

@ -35,6 +35,11 @@ class Tool implements EntityInterface
$this->interventions = new ArrayCollection(); $this->interventions = new ArrayCollection();
} }
public function __toString()
{
return $this->getLabel();
}
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;

View file

@ -13,17 +13,34 @@ class InterventionType extends AbstractType
{ {
$builder $builder
->add('activityReference') ->add('activityReference')
->add('date') ->add('date', null, [
'html5' => true,
'widget' => 'single_text',
])
->add('groups') ->add('groups')
->add('levels') ->add('levels')
->add('themes') ->add('themes', null, [
->add('content') 'attr' => ['rows' => 5],
->add('toolsDetails') ])
->add('feedback') ->add('content', null, [
->add('vigilantPoints') 'attr' => ['rows' => 7],
->add('speaker') ])
->add('tools', null, [
'expanded' => true,
])
->add('toolsDetails', null, [
'attr' => ['rows' => 5],
])
->add('feedback', null, [
'attr' => ['rows' => 5],
])
->add('vigilantPoints', null, [
'attr' => ['rows' => 5],
])
->add('speakers', null, [
'expanded' => true,
])
->add('establishment') ->add('establishment')
->add('tools')
; ;
} }

View file

@ -0,0 +1,13 @@
<div class="row">
<div class="col-md-3">
{% for item in ['establishment', 'activityReference', 'date', 'groups', 'levels', 'speakers'] %}
{% include(configuration.view('form_widget', '@Core/admin/crud/_form_widget.html.twig')) with {form: form[item]} %}
{% endfor %}
</div>
<div class="col-md-9 pl-md-3">
{% for item in ['themes', 'content', 'tools', 'toolsDetails', 'feedback', 'vigilantPoints'] %}
{% include(configuration.view('form_widget', '@Core/admin/crud/_form_widget.html.twig')) with {form: form[item]} %}
{% endfor %}
</div>
</div>

View file

@ -2,4 +2,13 @@
"Zip code": "Code postal" "Zip code": "Code postal"
"City": "Ville" "City": "Ville"
"Speaker": "Intervenant⋅e" "Speaker": "Intervenant⋅e"
"Speakers": "Intervenant⋅e⋅s"
"Establishment": "Établissement" "Establishment": "Établissement"
"Activity reference": "Activité de référence"
"Groups": "Groupe(s)"
"Levels": "Niveau(x)"
"Themes": "Thématiques abordées"
"Tools": "Outils et supports"
"Tools details": "Détails outils et supports"
"Feedback": "Les retours des participant⋅e⋅s"
"Vigilant points": "Point(s) de vigilance observé(s) par l'intervenant⋅e"