update form
This commit is contained in:
4
templates/post/_delete_form.html.twig
Normal file
4
templates/post/_delete_form.html.twig
Normal file
@@ -0,0 +1,4 @@
|
||||
<form method="post" action="{{ path('app_post_delete', {'id': post.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ post.id) }}">
|
||||
<button class="btn">Delete</button>
|
||||
</form>
|
4
templates/post/_form.html.twig
Normal file
4
templates/post/_form.html.twig
Normal file
@@ -0,0 +1,4 @@
|
||||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<button class="btn">{{ button_label|default('Save') }}</button>
|
||||
{{ form_end(form) }}
|
@@ -5,11 +5,9 @@
|
||||
{% block body %}
|
||||
<h1>Edit Post</h1>
|
||||
|
||||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
{{ include('post/_form.html.twig', {'button_label': 'Update'}) }}
|
||||
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
{{ form_end(form) }}
|
||||
<a href="{{ path('app_post_index') }}">back to list</a>
|
||||
|
||||
<a href="{{ path('app_posts') }}" class="btn btn-secondary">Back to posts</a>
|
||||
{% endblock %}
|
||||
{{ include('post/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
|
@@ -1,11 +1,45 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Posts!{% endblock %}
|
||||
{% block title %}Post index{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
{% for post in posts %}
|
||||
<div class="card">
|
||||
#{{ post.id }} trouvé le {{ post.foundDate | date("d/m/Y \\à H \\h") }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<h1>Post index</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>FoundDate</th>
|
||||
<th>PublicationDate</th>
|
||||
<th>Latitude</th>
|
||||
<th>Longitude</th>
|
||||
<th>Altitude</th>
|
||||
<th>Commentary</th>
|
||||
<th>actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for post in posts %}
|
||||
<tr>
|
||||
<td>{{ post.id }}</td>
|
||||
<td>{{ post.foundDate ? post.foundDate|date('Y-m-d H:i:s') : '' }}</td>
|
||||
<td>{{ post.publicationDate ? post.publicationDate|date('Y-m-d H:i:s') : '' }}</td>
|
||||
<td>{{ post.latitude }}</td>
|
||||
<td>{{ post.longitude }}</td>
|
||||
<td>{{ post.altitude }}</td>
|
||||
<td>{{ post.commentary }}</td>
|
||||
<td>
|
||||
<a href="{{ path('app_post_show', {'id': post.id}) }}">show</a>
|
||||
<a href="{{ path('app_post_edit', {'id': post.id}) }}">edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="8">no records found</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('app_post_new') }}">Create new</a>
|
||||
{% endblock %}
|
||||
|
11
templates/post/new.html.twig
Normal file
11
templates/post/new.html.twig
Normal file
@@ -0,0 +1,11 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}New Post{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Create new Post</h1>
|
||||
|
||||
{{ include('post/_form.html.twig') }}
|
||||
|
||||
<a href="{{ path('app_post_index') }}">back to list</a>
|
||||
{% endblock %}
|
@@ -1,3 +0,0 @@
|
||||
{{ form_start(form, {'attr': {'novalidate': 'novalidate'}}) }}
|
||||
{{ form_widget(form) }}
|
||||
{{ form_end(form) }}
|
46
templates/post/show.html.twig
Normal file
46
templates/post/show.html.twig
Normal file
@@ -0,0 +1,46 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Post{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Post</h1>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ post.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>FoundDate</th>
|
||||
<td>{{ post.foundDate ? post.foundDate|date('Y-m-d H:i:s') : '' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>PublicationDate</th>
|
||||
<td>{{ post.publicationDate ? post.publicationDate|date('Y-m-d H:i:s') : '' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Latitude</th>
|
||||
<td>{{ post.latitude }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Longitude</th>
|
||||
<td>{{ post.longitude }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Altitude</th>
|
||||
<td>{{ post.altitude }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Commentary</th>
|
||||
<td>{{ post.commentary }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('app_post_index') }}">back to list</a>
|
||||
|
||||
<a href="{{ path('app_post_edit', {'id': post.id}) }}">edit</a>
|
||||
|
||||
{{ include('post/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
Reference in New Issue
Block a user