Réalisation du tp3, tp4, tp5 et tp6 avec documentation.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<h2>Modifier {{ $product->name }}</h2>
|
||||
|
||||
{{-- TP5 : erreurs de validation de la modification. --}}
|
||||
@if ($errors->any())
|
||||
<div role="alert">
|
||||
<strong>Des erreurs sont présentes :</strong>
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('products.update', $product) }}">
|
||||
{{-- TP4 : @method('PUT') permet la route products.update. --}}
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
{{-- TP5 : old() conserve la saisie après une erreur. --}}
|
||||
<label for="name">Nom</label>
|
||||
<input id="name" type="text" name="name" value="{{ old('name', $product->name) }}" required>
|
||||
@error('name') <div role="alert">{{ $message }}</div> @enderror
|
||||
|
||||
<label for="price">Prix (EUR)</label>
|
||||
<input id="price" type="number" name="price" min="0" step="0.01" value="{{ old('price', $product->price) }}" required>
|
||||
@error('price') <div role="alert">{{ $message }}</div> @enderror
|
||||
|
||||
<label for="stock">Stock</label>
|
||||
<input id="stock" type="number" name="stock" min="0" value="{{ old('stock', $product->stock) }}" required>
|
||||
@error('stock') <div role="alert">{{ $message }}</div> @enderror
|
||||
|
||||
<button type="submit">Mettre à jour</button>
|
||||
</form>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user