dependsOn does not work if used in a Repeatable field
Detailed steps to reproduce the issue on a fresh Nova installation:
<?php
namespace App\Nova;
use App\Nova\Repeater\NotificationChannels;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Repeater;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
class NotificationProfile extends Resource
{
public static $model = \App\Models\NotificationProfile::class;
public static $title = 'name';
public static $search = [
'name',
];
public function fields(NovaRequest $request)
{
return [
ID::make()->sortable(),
Text::make('Name')->sortable(),
Repeater::make('Notification Channels')
->repeatables([
NotificationChannels::make(),
]),
];
}
}
<?php
namespace App\Nova\Repeater;
use App\Models\NotificationChannel;
use Laravel\Nova\Fields\Repeater\Repeatable;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\FormData;
use Laravel\Nova\Http\Requests\NovaRequest;
class NotificationChannels extends Repeatable
{
public function fields(NovaRequest $request): array
{
return [
Select::make('Type', 'type')
->options([
'email' => 'Email',
'telegram' => 'Telegram',
])
->displayUsingLabels(),
Select::make('Config')
->options([
'channel' => 'Channel',
'private' => 'Private',
])
->hide()
->dependsOn(
['type'],
function (Text $field, NovaRequest $request, FormData $formData) {
if ($formData->type == 'telegram') {
$field->show()->rules('required');
}
}
),
];
}
}
Description:
dependsOn does not work if used in a Repeatable field
Detailed steps to reproduce the issue on a fresh Nova installation: