Dependant Field not working on Action Field #6679
-
Description:Dependant Field not working on Action Field Detailed steps to reproduce the issue on a fresh Nova installation:Create Action with action field. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Unable to reproduce the issue, please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example) |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
<?php
namespace App\Nova\Actions;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Collection;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Actions\ActionResponse;
use Laravel\Nova\Fields\ActionFields;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\FormData;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
class TestAction extends Action
{
use InteractsWithQueue;
use Queueable;
/**
* Perform the action on the given models.
*
* @return mixed
*/
public function handle(ActionFields $fields, Collection $models)
{
//
}
/**
* Get the fields available on the action.
*
* @return array<int, \Laravel\Nova\Fields\Field>
*/
public function fields(NovaRequest $request): array
{
return [
Boolean::make('Boolean', 'boolean'),
Text::make('Text', 'text')
->hide()
->dependsOn('boolean', function (Text $field, NovaRequest $request, FormData $formData) {
- if ($formData->boolean) $field->show();
+ if ($formData->boolean('boolean')) $field->show();
}),
];
}
} |
Beta Was this translation helpful? Give feedback.
<?php namespace App\Nova\Actions; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Collection; use Laravel\Nova\Actions\Action; use Laravel\Nova\Actions\ActionResponse; use Laravel\Nova\Fields\ActionFields; use Laravel\Nova\Fields\Boolean; use Laravel\Nova\Fields\FormData; use Laravel\Nova\Fields\Text; use Laravel\Nova\Http\Requests\NovaRequest; class TestAction extends Action { use InteractsWithQueue; use Queueable; /** * Perform the action on the given models. * * @return mixed */ public function handle(ActionFields $fields, Collection $models) { /…