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

error on $field "Illegal offset type in isset or empty" laravel nova 4 #24

Closed HAL0594 closed 1 year ago

HAL0594 commented 1 year ago

I'm trying to make a radio dependent on another one that should only show and be required with one of the above radio options but when trying to assign $field->show()->rules('required'); show the error mesage "Illegal offset type in isset or empty".

        Radio::make(__('Duration'), 'duration')->options([
            'none' => __('None'),
            'half_day' => __('Half Day'),
            'full_day' => __('Full Day'),
        ])->rules('required'),

        Radio::make(__('Schedule'), 'schedule')
            ->hide()->options(['am' => __('am'), 'pm' => __('pm')])
            ->dependsOn(['duration'], function (Radio $field, NovaRequest $request, FormData $formData) {
                if ($formData->duration === "half_day") {
                    $field->show()->rules('required');
                } else {
                    $field->hide()->rules('nullable');
                }
            }),
Muetze42 commented 1 year ago

Please try newest release:

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