Skip to content
This repository has been archived by the owner on Jun 26, 2022. It is now read-only.

Repetitive id single-select on page; not able to depend on select value #23

Open
rela589n opened this issue Jan 15, 2021 · 0 comments
Open

Comments

@rela589n
Copy link

On the screenshots below you can see the problem:

image
image

I faced not exactly this problem, but that I am not able to depend on selected value with NovaDependencyContainer (probably because on the input there is no id set. Hope it will be fixed

Steps to reproduce:

Create migration:

      Schema::create('test_subjects', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name', 128);
        });

Create model.

Create action:

namespace App\Nova\Actions;

use App\Models\TestSubject;
use Epartment\NovaDependencyContainer\NovaDependencyContainer;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Collection;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Fields\ActionFields;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
use Techouse\SelectAutoComplete\SelectAutoComplete;

class AttachTestsQuestionsToTest extends Action
{
    use InteractsWithQueue, Queueable;

    public function handle(ActionFields $fields, Collection $models)
    {
        dump($fields);
        dd($models);
    }

    public function fields()
    {
        return [
            SelectAutoComplete::make('Test Subject2', 'test_subject2')
                ->options(
                    $subjects->mapWithKeys(
                        fn(TestSubject $subject) => [$subject->id => "({$subject->id}) {$subject->name}"]
                    )
                )
                ->displayUsingLabels(),

            NovaDependencyContainer::make(
                [
                    Text::make('second when test_subject is 3')
                ]
            )->dependsOn('test_subject2', 3),
        ];
    }
}
@rela589n rela589n changed the title Repetitive id single-select on page Repetitive id single-select on page; not able to depend on select value Jan 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant