whitecube / nova-flexible-content

Flexible Content & Repeater Fields for Laravel Nova
MIT License
787 stars 234 forks source link

The dependsOn is not working in the field inside Flexible #524

Open kennethtomagan opened 2 months ago

kennethtomagan commented 2 months ago

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?

daanadriaan commented 1 month ago

Anyone found a solution?

nzmattman commented 3 weeks ago

i have the same issue i wonder if it may have to do with the nested json when selecting the fields it depends on

lucasff commented 2 weeks ago

this is the same issue the parent dependsOn and official Nova Repeatable item is suffering.

matthbon commented 2 weeks ago

I also have this issue. Want to have dependant fields inside the Flexible. But it isn't working.

kennethtomagan commented 2 weeks ago

I also have this issue. Want to have dependant fields inside the Flexible. But it isn't working.

Right now, I do it by creating a custom field and put it inside Flexible. In my custom field I create a JS functionality to get the value of dependents field.

It's a bit complicated so I hope it will be fixed sooner.

daanadriaan commented 2 weeks ago

Right now, I do it by creating a custom field and put it inside Flexible. In my custom field I create a JS functionality to get the value of dependents field.

@kennethtomagan Snippet?

matthbon commented 2 weeks ago

I also have this issue. Want to have dependant fields inside the Flexible. But it isn't working.

Right now, I do it by creating a custom field and put it inside Flexible. In my custom field I create a JS functionality to get the value of dependents field.

It's a bit complicated so I hope it will be fixed sooner.

@kennethtomagan a snippet would be nice?