diff --git a/app/Http/Controllers/FoodController.php b/app/Http/Controllers/FoodController.php
index b55538f..fc9d4bb 100644
--- a/app/Http/Controllers/FoodController.php
+++ b/app/Http/Controllers/FoodController.php
@@ -53,8 +53,15 @@ class FoodController extends Controller
*/
public function edit(Food $food): View
{
+ // Convert string tags (from old form data) to a Collection.
+ $food_tags = old('tags', $food->tags->pluck('name'));
+ if (is_string($food_tags)) {
+ $food_tags = new Collection(explode(',', $food_tags));
+ }
+
return view('foods.edit')
->with('food', $food)
+ ->with('food_tags', $food_tags)
->with('nutrients', Nutrients::$all)
->with('serving_units', new Collection([
['value' => 'tsp', 'label' => 'tsp.'],
diff --git a/app/Http/Controllers/RecipeController.php b/app/Http/Controllers/RecipeController.php
index 37ec01b..4d3fa2d 100644
--- a/app/Http/Controllers/RecipeController.php
+++ b/app/Http/Controllers/RecipeController.php
@@ -125,8 +125,15 @@ class RecipeController extends Controller
}
}
+ // Convert string tags (from old form data) to a Collection.
+ $recipe_tags = old('tags', $recipe->tags->pluck('name'));
+ if (is_string($recipe_tags)) {
+ $recipe_tags = new Collection(explode(',', $recipe_tags));
+ }
+
return view('recipes.edit')
->with('recipe', $recipe)
+ ->with('recipe_tags', $recipe_tags)
->with('ingredients', $ingredients)
->with('steps', $steps)
->with('ingredients_units', Nutrients::$units);
diff --git a/resources/views/foods/edit.blade.php b/resources/views/foods/edit.blade.php
index 90d86ee..61ea2ec 100644
--- a/resources/views/foods/edit.blade.php
+++ b/resources/views/foods/edit.blade.php
@@ -66,7 +66,8 @@
type="text"
name="serving_size"
size="10"
- :value="old('serving_size', $old_value)"/>
+ :value="old('serving_size', $old_value)"
+ required/>
@@ -91,7 +92,8 @@
step="any"
name="serving_weight"
size="10"
- :value="old('serving_weight', $food->serving_weight)"/>
+ :value="old('serving_weight', $food->serving_weight)"
+ required/>
@@ -113,7 +115,7 @@
-