diff --git a/app/View/Components/Form/Group/Account.php b/app/View/Components/Form/Group/Account.php index bc00fb809..744c98070 100644 --- a/app/View/Components/Form/Group/Account.php +++ b/app/View/Components/Form/Group/Account.php @@ -28,6 +28,18 @@ class Account extends Form $this->accounts = $this->getAccounts(); + $account_id = old('account.id', old('account_id', null)); + + if (! empty($account_id)) { + $this->selected = $account_id; + + if (! $this->accounts->has($account_id)) { + $account = Model::find($account_id); + + $this->accounts->put($account->id, $account->name); + } + } + if (empty($this->selected) && empty($this->getParentData('model'))) { $this->selected = setting('default.account'); } diff --git a/app/View/Components/Form/Group/Category.php b/app/View/Components/Form/Group/Category.php index 6e9e8b6c5..03e089655 100644 --- a/app/View/Components/Form/Group/Category.php +++ b/app/View/Components/Form/Group/Category.php @@ -33,6 +33,18 @@ class Category extends Form $model = $this->getParentData('model'); + $category_id = old('category.id', old('category_id', null)); + + if (! empty($category_id)) { + $this->selected = $category_id; + + if (! $this->categories->has($category_id)) { + $category = Model::find($category_id); + + $this->categories->put($category->id, $category->name); + } + } + if (! empty($model) && ! empty($model->category_id)) { $this->selected = $model->category_id; diff --git a/app/View/Components/Form/Group/Contact.php b/app/View/Components/Form/Group/Contact.php index ef0909a78..58e0d882d 100644 --- a/app/View/Components/Form/Group/Contact.php +++ b/app/View/Components/Form/Group/Contact.php @@ -39,6 +39,18 @@ class Contact extends Form $model = $this->getParentData('model'); + $contact_id = old('contact.id', old('contact_id', null)); + + if (! empty($contact_id)) { + $this->selected = $contact_id; + + if (! $this->contacts->has($contact_id)) { + $contact = Model::find($contact_id); + + $this->contacts->put($contact->id, $contact->name); + } + } + if (! empty($model) && ! empty($model->contact_id)) { $this->selected = $model->contact_id; diff --git a/app/View/Components/Form/Group/Currency.php b/app/View/Components/Form/Group/Currency.php index bd3628826..2ffc0febd 100644 --- a/app/View/Components/Form/Group/Currency.php +++ b/app/View/Components/Form/Group/Currency.php @@ -35,6 +35,18 @@ class Currency extends Form $this->currencies = Model::enabled()->orderBy('name')->pluck('name', 'code'); + $currency_id = old('currency.id', old('currency_id', null)); + + if (! empty($currency_id)) { + $this->selected = $currency_id; + + if (! $this->currencies->has($currency_id)) { + $currency = Model::find($currency_id); + + $this->currencies->put($currency->id, $currency->name); + } + } + if (empty($this->selected) && empty($this->getParentData('model'))) { $this->selected = setting('default.currency'); } diff --git a/app/View/Components/Form/Group/Tax.php b/app/View/Components/Form/Group/Tax.php index a154674f1..7308d6252 100644 --- a/app/View/Components/Form/Group/Tax.php +++ b/app/View/Components/Form/Group/Tax.php @@ -40,7 +40,7 @@ class Tax extends Form if (! empty($tax_id)) { $this->selected = $tax_id; - if ($this->taxes->has($tax_id)) { + if (! $this->taxes->has($tax_id)) { $tax = Model::find($tax_id); $this->taxes->put($tax->id, $tax->name);