Incident commit avec en plus Form et twig
This commit is contained in:
parent
8eabb71db4
commit
d4928755cd
33
src/Form/IncidentType.php
Normal file
33
src/Form/IncidentType.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Employee;
|
||||
use App\Entity\Incident;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class IncidentType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('description',
|
||||
TextareaType::class)
|
||||
->add('employee', EntityType::class, ['class' => Employee::class, 'choice_label' => 'firstname'])
|
||||
// ->add('incidentType', EntityType::class, ['class' => IncidentType::class, 'choice_label' => 'id'])
|
||||
->add('Enregistrer', SubmitType::class)
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
// Configure your form options here
|
||||
]);
|
||||
}
|
||||
}
|
30
templates/incident/index.html.twig
Normal file
30
templates/incident/index.html.twig
Normal file
@ -0,0 +1,30 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Incident index{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Incident index</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for incident in incidents %}
|
||||
<tr>
|
||||
<td>{{ incident.id }}</td>
|
||||
<td>{{ incident.description }}</td>
|
||||
<td>
|
||||
<a href="{{ path('incident_show', {'id' : incident.id}) }}">show</a>
|
||||
<a href="{{ path('incident_edit', {'id' : incident.id}) }}">edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('incident_new') }}">Create new</a>
|
||||
{% endblock %}
|
11
templates/incident/new.html.twig
Normal file
11
templates/incident/new.html.twig
Normal file
@ -0,0 +1,11 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}New Incident{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Create new Incident</h1>
|
||||
|
||||
{{ form(formNew,{'attr': {'novalidate': 'novalidate'}}) }}
|
||||
|
||||
<a href="{{ path('incident_index') }}">back to list</a>
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user