Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kennethtomagan opened this issue Sep 2, 2024 · 7 comments
Open

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

kennethtomagan opened this issue Sep 2, 2024 · 7 comments

Comments

@kennethtomagan
Copy link

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
Copy link

Anyone found a solution?

@nzmattman
Copy link

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
Copy link

lucasff commented Oct 16, 2024

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

@kennethtomagan kennethtomagan changed the title THe dependsOn is not working in the field inside Flexible The dependsOn is not working in the field inside Flexible Oct 17, 2024
@matthbon
Copy link

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

@kennethtomagan
Copy link
Author

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
Copy link

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
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants