Muetze42 / nova-radio-field

A Radio Buttons field for Laravel Nova.
https://novapackages.com/packages/norman-huth/nova-radio-field
MIT License
5 stars 2 forks source link

dependsOn the Radiofield #9

Closed CodeWithDennis closed 1 year ago

CodeWithDennis commented 1 year ago

It seems like the Radiofield is not working when using dependsOn on the field it self, the type field is also a Radiofield.

Radio::make(__('Type'), 'type')
    ->options([
          'mail' => 'Email',
          'phone' => 'Telefonisch'
     ])
      ->default('mail')
      ->gap(5)
      ->inline(),
Radio::make(__('method'), 'method')
     ->dependsOn(['type'], function (Radio $field, NovaRequest $request, FormData $formData) {
      if ($formData->type == 'phone') {
          $field->show();
      }
})->hide(),

The field will not show. (added video clip) https://user-images.githubusercontent.com/23448484/235426360-3b4ab5c6-24d0-4400-815f-2e38e0b738fc.mov

Muetze42 commented 1 year ago

Brief sign of life. I have not forgotten this, but unfortunately have not yet had a chance to look at it. Please still a little patience.

And thanks for the message.

Muetze42 commented 1 year ago

So. a little late, but I checked again everything at the Nova Select field and refactor everything and it works now in both directions.

https://github.com/Muetze42/nova-radio-field/releases

CodeWithDennis commented 1 year ago

Thanks!

CodeWithDennis commented 1 year ago

@Muetze42 Sorry to bother you again but it seems like there is still something going wrong with dependsOn the options are not changing. When trying the exact same code on the Select field it works.

Radio::make(__('Methode'), 'method')
                ->options([
                    'test123' => 'test123',
                    'test321' => 'test321'
                ])
                ->dependsOn(['type'], function (Radio $field, NovaRequest $request, FormData $formData) {
                    if ($formData->type == 'phone') {
                        $field->options(['test' => 'test']);
                    }
                })->inline(),

https://user-images.githubusercontent.com/23448484/236164148-2fb60b8e-e31f-4fc2-8abf-7b20857cd40a.mov

Muetze42 commented 1 year ago

I think we have it now. :D Bit stupid, since dependsOn is not documented. But thanks for your reports.

Select dependsOn Radio (M/Medium):
Live: https://nova-demo.huth.it/resources/nova-radio-field-radios/2/edit
Source: https://github.com/Muetze42/laravel-nova-demo-app/blob/main/app/Nova/Resources/NovaRadioFieldRadio.php#L111

Radio dependsOn Select (M/Medium):
Live: https://nova-demo.huth.it/resources/nova-radio-field-radios/3/edit
Source: https://github.com/Muetze42/laravel-nova-demo-app/blob/main/app/Nova/Resources/NovaRadioFieldRadio.php#L146

Change Radio dependsOn (W/With help texts):
Live: https://nova-demo.huth.it/resources/nova-radio-field-radios/4/edit
Source: https://github.com/Muetze42/laravel-nova-demo-app/blob/main/app/Nova/Resources/NovaRadioFieldRadio.php#L181

Everything from version 1.1.3

CodeWithDennis commented 1 year ago

Nice! It seems to be working now.

PS: i think the same issue is going for readonly() but i won't bother you with that since i don't need it.

Muetze42 commented 1 year ago

Oh man. 😭 It's on my to-do. But not today. 😄

CodeWithDennis commented 1 year ago

Oh man. 😭 It's on my to-do. But not today. 😄

Haha no worries, i appreciate all the quick fixes you done so far!

Muetze42 commented 1 year ago

In case you need readonly. Now it is available....