diff --git a/app/Http/Livewire/CustomFieldSetDefaultValuesForModel.php b/app/Http/Livewire/CustomFieldSetDefaultValuesForModel.php index c9478c054a..6816edea7f 100644 --- a/app/Http/Livewire/CustomFieldSetDefaultValuesForModel.php +++ b/app/Http/Livewire/CustomFieldSetDefaultValuesForModel.php @@ -19,13 +19,22 @@ class CustomFieldSetDefaultValuesForModel extends Component { $this->model = AssetModel::find($this->model_id); // It's possible to do some clever route-model binding here, but let's keep it simple, shall we? $this->fieldset_id = $this->model->fieldset_id; - $this->fields = CustomFieldset::find($this->fieldset_id)->fields; - $this->add_default_values = ( $this->model->defaultValues->count() > 0); + + $this->fields = null; + + if ($fieldset = CustomFieldset::find($this->fieldset_id)) { + $this->fields = CustomFieldset::find($this->fieldset_id)->fields; + } + + $this->add_default_values = ($this->model->defaultValues->count() > 0); } public function updatedFieldsetId() { - $this->fields = CustomFieldset::find($this->fieldset_id)->fields; + if (CustomFieldset::find($this->fieldset_id)) { + $this->fields = CustomFieldset::find($this->fieldset_id)->fields; + } + } public function render() diff --git a/resources/views/livewire/custom-field-set-default-values-for-model.blade.php b/resources/views/livewire/custom-field-set-default-values-for-model.blade.php index b296b7bc56..c1a8373f47 100644 --- a/resources/views/livewire/custom-field-set-default-values-for-model.blade.php +++ b/resources/views/livewire/custom-field-set-default-values-for-model.blade.php @@ -12,9 +12,10 @@ - @if( $this->add_default_values ) {{-- 'if the checkbox is enabled *AND* there are more than 0 fields in the fieldsset' --}} + @if ($this->add_default_values ) {{-- 'if the checkbox is enabled *AND* there are more than 0 fields in the fieldsset' --}}