connexion base et création premier crud

This commit is contained in:
Logshiro
2025-10-16 17:01:43 +02:00
parent ea9a187326
commit 2e4dce40d4
38 changed files with 653 additions and 278 deletions

View File

@@ -1,4 +1,4 @@
<form method="post" action="{{ path('app_membre_delete', {'id': membre.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ membre.id) }}">
<button class="btn">Delete</button>
<button class="btn btn-danger">Delete</button>
</form>

View File

@@ -1,4 +1,4 @@
{{ form_start(form) }}
{{ form_widget(form) }}
<button class="btn">{{ button_label|default('Save') }}</button>
<button class="btn btn-primary">{{ button_label|default('Save') }}</button>
{{ form_end(form) }}

View File

@@ -3,11 +3,16 @@
{% block title %}Edit Membre{% endblock %}
{% block body %}
<h1>Edit Membre</h1>
{{ include('membre/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('app_membre_index') }}">back to list</a>
{{ include('membre/_delete_form.html.twig') }}
<div class="card mb-3">
<div class="card-header">
<h1 class="h4 mb-0">Edit Membre</h1>
</div>
<div class="card-body">
{{ include('membre/_form.html.twig', {'button_label': 'Update'}) }}
<div class="d-flex gap-2 mt-2">
<a href="{{ path('app_membre_index') }}" class="btn btn-outline-secondary">Back to list</a>
{{ include('membre/_delete_form.html.twig') }}
</div>
</div>
</div>
{% endblock %}

View File

@@ -2,44 +2,37 @@
{% block title %}Membre index{% endblock %}
{% block stylesheets %}
{{ parent() }}
{# Ajouter Bootstrap depuis le CDN #}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
{% endblock %}
{% block body %}
<div class="container mt-4">
<h1 class="mb-4">Membre index</h1>
<table class="table table-striped table-bordered">
<thead class="table-dark">
<tr>
<th>Id</th>
<th>Nom</th>
<th>Password</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for membre in membres %}
<tr>
<td>{{ membre.id }}</td>
<td>{{ membre.nom }}</td>
<td>{{ membre.password }}</td>
<td>
<a href="{{ path('app_membre_show', {'id': membre.id}) }}" class="btn btn-sm btn-primary">Show</a>
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}" class="btn btn-sm btn-warning">Edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="4" class="text-center">No records found</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h3 mb-0">Membres</h1>
<a href="{{ path('app_membre_new') }}" class="btn btn-success">Create new</a>
</div>
<table class="table table-striped table-hover align-middle">
<thead>
<tr>
<th>Id</th>
<th>Nom</th>
<th>Droit</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
{% for membre in membres %}
<tr>
<td>{{ membre.id }}</td>
<td>{{ membre.nom }}</td>
<td>{{ membre.droit }}</td>
<td class="text-end">
<a href="{{ path('app_membre_show', {'id': membre.id}) }}" class="btn btn-sm btn-outline-primary me-1">Show</a>
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}" class="btn btn-sm btn-outline-secondary">Edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="5" class="text-center text-muted">No records found</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@@ -1,22 +0,0 @@
{# templates/membre/index.html.twig #}
<h1>Liste des Membres</h1>
<table border="1">
<thead>
<tr>
<th>ID</th>
<th>Nom</th>
<th>Droit</th>
</tr>
</thead>
<tbody>
{% for membre in membres %}
<tr>
<td>{{ membre.id }}</td>
<td>{{ membre.nom }}</td>
<td>{{ membre.droit ? membre.droit.nom : 'Aucun' }}</td>
</tr>
{% endfor %}
</tbody>
</table>

View File

@@ -3,9 +3,13 @@
{% block title %}New Membre{% endblock %}
{% block body %}
<h1>Create new Membre</h1>
{{ include('membre/_form.html.twig') }}
<a href="{{ path('app_membre_index') }}">back to list</a>
<div class="card">
<div class="card-header">
<h1 class="h4 mb-0">Create new Membre</h1>
</div>
<div class="card-body">
{{ include('membre/_form.html.twig') }}
<a href="{{ path('app_membre_index') }}" class="btn btn-outline-secondary mt-2">Back to list</a>
</div>
</div>
{% endblock %}

View File

@@ -3,9 +3,15 @@
{% block title %}Membre{% endblock %}
{% block body %}
<h1>Membre</h1>
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h3 mb-0">Membre #{{ membre.id }}</h1>
<div>
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}" class="btn btn-secondary me-2">Edit</a>
<a href="{{ path('app_membre_index') }}" class="btn btn-outline-secondary">Back to list</a>
</div>
</div>
<table class="table">
<table class="table table-bordered">
<tbody>
<tr>
<th>Id</th>
@@ -17,14 +23,16 @@
</tr>
<tr>
<th>Password</th>
<td>{{ membre.password }}</td>
<td>********</td>
</tr>
<tr>
<th>Droit</th>
<td>{{ membre.droit }}</td>
</tr>
</tbody>
</table>
<a href="{{ path('app_membre_index') }}">back to list</a>
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}">edit</a>
{{ include('membre/_delete_form.html.twig') }}
<div class="mt-3">
{{ include('membre/_delete_form.html.twig') }}
</div>
{% endblock %}