Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependant Field not working on Action Field #6678

Closed
laravelwebdev opened this issue Jan 19, 2025 · 2 comments
Closed

Dependant Field not working on Action Field #6678

laravelwebdev opened this issue Jan 19, 2025 · 2 comments
Labels
needs more info More information is required

Comments

@laravelwebdev
Copy link

  • Laravel Version: 11
  • Nova Version: 5
  • PHP Version: 8.3

Description:

Dependant Field not working on Action Field

Detailed steps to reproduce the issue on a fresh Nova installation:

Create Action with action field.
Create dependant field on action filed depend on another field (eg dependant hide, default, setvalue, option.

@crynobone
Copy link
Member

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)

@crynobone crynobone added the needs more info More information is required label Jan 19, 2025
@laravelwebdev
Copy link
Author

<?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();
            }),
        ];
    }
}

@laravel laravel locked and limited conversation to collaborators Jan 20, 2025
@crynobone crynobone converted this issue into discussion #6679 Jan 20, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
needs more info More information is required
Projects
None yet
Development

No branches or pull requests

2 participants