diff --git a/app/View/Components/Form/Group/Category.php b/app/View/Components/Form/Group/Category.php index 82d560752..6e9e8b6c5 100644 --- a/app/View/Components/Form/Group/Category.php +++ b/app/View/Components/Form/Group/Category.php @@ -33,7 +33,7 @@ class Category extends Form $model = $this->getParentData('model'); - if (! empty($model)) { + if (! empty($model) && ! empty($model->category_id)) { $this->selected = $model->category_id; $selected_category = $model->category; diff --git a/app/View/Components/Form/Group/Contact.php b/app/View/Components/Form/Group/Contact.php index 9baa00e51..ef0909a78 100644 --- a/app/View/Components/Form/Group/Contact.php +++ b/app/View/Components/Form/Group/Contact.php @@ -39,12 +39,14 @@ class Contact extends Form $model = $this->getParentData('model'); - if (! empty($model)) { + if (! empty($model) && ! empty($model->contact_id)) { $this->selected = $model->contact_id; - if (! $this->contacts->has($model->contact_id) && ($contact = $model->contact)) { - $this->contacts->put($contact->id, $contact->name); - } + $selected_contact = $model->contact; + } + + if (! empty($selected_contact) && ! $this->contacts->has($selected_contact->id)) { + $this->contacts->put($selected_contact->id, $selected_contact->name); } return view($this->view);