Check for NULL before fraction conversion

This commit is contained in:
Christopher C. Wells 2021-01-15 18:52:51 -08:00
parent 63f22274a5
commit f3f2dd8b6f
1 changed files with 8 additions and 1 deletions

View File

@ -67,6 +67,13 @@
<div class="flex items-center space-x-4"> <div class="flex items-center space-x-4">
<!-- Serving size --> <!-- Serving size -->
@php
if (!empty($food->serving_size)) {
$old_value = \App\Support\Number::fractionStringFromFloat($food->serving_size);
} else {
$old_value = null;
}
@endphp
<div> <div>
<x-inputs.label for="serving_size" :value="__('Serving size')"/> <x-inputs.label for="serving_size" :value="__('Serving size')"/>
@ -75,7 +82,7 @@
type="text" type="text"
name="serving_size" name="serving_size"
size="10" size="10"
:value="old('serving_size', \App\Support\Number::fractionStringFromFloat($food->serving_size))"/> :value="old('serving_size', $old_value)"/>
</div> </div>
<!-- Serving unit --> <!-- Serving unit -->