Dependent Fields only work on forms??? #6156
Unanswered
matthewjumpsoffbuildings
asked this question in
Q&A
Replies: 1 comment
-
I don't know if you still need the answer, but here it goes. DependsOn is for forms only as far as I can see, if you want to conditionally hide fields you could use the public function fields(NovaRequest $request)
{
return [
Text::make(__('Action Name'), 'name', fn ($value) => __($value))
->showOnPreview(),
BelongsTo::make(__('Action Initiated By'), 'user', User::class)
->filterable()
->showOnPreview(),
MorphToActionTarget::make(__('Action Target'), 'target')
->showOnPreview(),
Status::make(__('Action Status'), 'status', fn ($value) => __(ucfirst($value)))
->loadingWhen([__('Waiting'), __('Running')])
->failedWhen([__('Failed')]),
// See here!!!
$this->when(! empty($this->original), fn () => KeyValue::make(__('Original'), 'original')
->showOnPreview()),
$this->when(! empty($this->changes), fn () => KeyValue::make(__('Changes'), 'changes')
->showOnPreview()),
$this->when(! empty($this->exception), fn () => Textarea::make(__('Exception'), 'exception')
->showOnPreview()),
DateTime::make(__('Action Happened At'), 'created_at')
->showOnPreview(),
];
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to implement Dependent Fields and it seems to be the case that
dependsOn()
only gets called when in create or update views?Is there no way to make this work on detail views? I was hoping to simply show/hide certain fields based on the value of another field, but it seems like this wont work? Or am I missing something
Beta Was this translation helpful? Give feedback.
All reactions