Skip to content

4.13.0 appears to break dependsOn (possible regression) #4751

@sidawson

Description

@sidawson
  • 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:

  1. Create a nova page, based on a table that has two interdependent fields.

eg,

  • table ticket - has a customer_id and a customer_contract_id.
  • ticket HasMany customers
  • customer 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(),

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions