outl1ne / nova-simple-repeatable

A Laravel Nova simple repeatable rows field.
MIT License
73 stars 44 forks source link

fix broken dependsOn functionality #58

Closed miagg closed 1 week ago

miagg commented 7 months ago

This will fix javascript error that prevents dependsOn functionality on the latest Laravel Nova version (see attached video)

Example to reproduce

Boolean::make('toggle'),
SimpleRepeatable::make('repeater', [
    // Some fields
])->dependsOn('toggle', function (SimpleRepeatable $field, NovaRequest $request, FormData $formData) {
    $field->show($formData->test);
}),

https://github.com/outl1ne/nova-simple-repeatable/assets/6439071/a3b07d37-f412-45a4-9d5b-78b8d0fc7aa8

adampachowicz commented 5 months ago

I have the same problem. Can you @KasparRosin merge this fix?

AshutoshJha15 commented 4 months ago

@miagg Bro, can you check? setValue is not working

Norgul commented 3 months ago

Maybe slightly off topic, but can dependsOn function with inner fields? Like this:

SimpleRepeatable::make('Repeat this', 'products', [
    Multiselect::make('Products')->asyncResource(Product::class)->singleSelect(),
    Text::make('Unit')->dependsOn('products', function (BelongsTo $field, NovaRequest $request, FormData $formData) {
        ...
    }),
    ...

Edit: I see the same question on https://github.com/outl1ne/nova-simple-repeatable/issues/28, so will direct any further communication there Edit2: I have created a PR for what I asked for https://github.com/outl1ne/nova-simple-repeatable/pull/61