nova-flexible-content icon indicating copy to clipboard operation
nova-flexible-content copied to clipboard

The dependsOn is not working in the field inside Flexible

Open kennethtomagan opened this issue 1 year ago • 12 comments

I want to change the Price field value depends on Product field, sane field is inside Flexible but dependsOn is not working.

Flexible::make('Order items')
    ->addLayout('Select Products', 'product', [
        Select::make('Product')
            ->options(Product::all()->pluck('name', 'id'))
            ->displayUsingLabels()
            ->searchable(),
        Text::make('Price')
        ->dependsOn(["product"], function (Text $field, NovaRequest $request, FormData $formData) {
                if ($formData->product) {
                    $productId = $formData->product;
                    $product = Product::find($productId);
                    $field->withMeta(['value' => $product->price]);
                }
        }),
    ])
    ->button('Add Product')
    ->fullWidth()
    ->limit(10),

anyone encounters this error? how do you guys solve it?

kennethtomagan avatar Sep 02 '24 06:09 kennethtomagan