Import Action Relation with OptionForm

:cool_tofu:
:squint:

How to import CSV data using getOptionsFormComponents,
For example, I want to import student data, for school_id I select it via the form, please help me where the error is.

studentImporter :

    public static function getOptionsFormComponents(): array
    {
        return [
            Select::make('school_id')
                ->relationship('school', 'name')
                ->searchable()
                ->required()
                ->preload(),

        ];
    }

resolveRecord
   public function resolveRecord(): ?Siswa
    {
        if ($this->options['school_id'] ?? false) {
            return Sekolah::firstOrNew([
                'school_id' => $this->data['school_id'],
            ]);
        }

        return new Siswa();
    }


erros:
Undefined array key "school_id"
Screenshot_2024-03-02_at_04.37.07.png
Was this page helpful?