adding Beer entity, migration and crud

This commit is contained in:
2021-02-18 20:13:14 +01:00
parent e1d462311f
commit 0fdd876bc4
11 changed files with 362 additions and 0 deletions

View File

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

View File

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

View File

@@ -0,0 +1,13 @@
{% extends 'base.html.twig' %}
{% block title %}Edit Beer{% endblock %}
{% block body %}
<h1>Edit Beer</h1>
{{ include('beer/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('beer_index') }}">back to list</a>
{{ include('beer/_delete_form.html.twig') }}
{% endblock %}

View File

@@ -0,0 +1,37 @@
{% extends 'base.html.twig' %}
{% block title %}Beer index{% endblock %}
{% block body %}
<h1>Beer index</h1>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Alcool</th>
<th>actions</th>
</tr>
</thead>
<tbody>
{% for beer in beers %}
<tr>
<td>{{ beer.id }}</td>
<td>{{ beer.name }}</td>
<td>{{ beer.alcool }}</td>
<td>
<a href="{{ path('beer_show', {'id': beer.id}) }}">show</a>
<a href="{{ path('beer_edit', {'id': beer.id}) }}">edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="4">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href="{{ path('beer_new') }}">Create new</a>
{% endblock %}

View File

@@ -0,0 +1,11 @@
{% extends 'base.html.twig' %}
{% block title %}New Beer{% endblock %}
{% block body %}
<h1>Create new Beer</h1>
{{ include('beer/_form.html.twig') }}
<a href="{{ path('beer_index') }}">back to list</a>
{% endblock %}

View File

@@ -0,0 +1,30 @@
{% extends 'base.html.twig' %}
{% block title %}Beer{% endblock %}
{% block body %}
<h1>Beer</h1>
<table class="table">
<tbody>
<tr>
<th>Id</th>
<td>{{ beer.id }}</td>
</tr>
<tr>
<th>Name</th>
<td>{{ beer.name }}</td>
</tr>
<tr>
<th>Alcool</th>
<td>{{ beer.alcool }}</td>
</tr>
</tbody>
</table>
<a href="{{ path('beer_index') }}">back to list</a>
<a href="{{ path('beer_edit', {'id': beer.id}) }}">edit</a>
{{ include('beer/_delete_form.html.twig') }}
{% endblock %}