-
Notifications
You must be signed in to change notification settings - Fork 35
Closed as not planned
Labels
Description
- Laravel Version: 8.83.23
- Nova Version: 4.13.0
- PHP Version: 8.1.9
- Database Driver & Version: mariadb 10.8.3
- Operating System and Version: macOS 12.3.1
- Browser type and version: Chrome 103.0.5060.114
- Reproduction Repository: https://github.com/###/###
Description:
BelongsTo with a Select::make using ->dependsOn worked on 4.12.14. Does not work on 4.13.0
Detailed steps to reproduce the issue on a fresh Nova installation:
- Create a nova page, based on a table that has two interdependent fields.
eg,
- table
ticket- has acustomer_idand acustomer_contract_id. ticket HasMany customerscustomer HasMany customer_contracts
use App\Models\Customer;
use App\Models\CustomerContract;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\FormData;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Http\Requests\NovaRequest;
BelongsTo::make('Customer'),
// display
BelongsTo::make('Customer Contract', 'customer_contract')
->exceptOnForms(),
// edit
Select::make('Customer Contract', 'customer_contract_id')
->dependsOn('customer', function(Select $field, NovaRequest $request, FormData $formData) {
$customer = Customer::whereId($formData->customer ?? $this->customer_id)->first();
$field->options($customer?->customer_contracts->pluck('description', 'id'));
})
->onlyOnForms(),
- Select a Customer (ie, any element from the parent table dropdown)
Expected behaviour (seen only in nova 4.12.14)
When a Customer is selected, the Customer Contract dropdown is limited to contracts owned by that customer
Observed behaviour (seen only in nova 4.13.0)
When a Customer is selected, the Customer Contract dropdown disappears from the screen completely
danielfaulknor, kusab85 and mkakpabla