open-admin-org/open-admin

Error when try to use Grid Tools action

uluumbch opened this issue · 2 comments

I follow custom headers tool in Grid Tools from documentation Normal Action but this always return error whenever i make to submit form from the Action class


class ChangeStatusPage extends Action
{
    public $name = 'Ubah Status Massal';

    protected $selector = '.change-status-page';

    public function handle(Request $request)
    {
         return $this->response()->success('Import complete!')->refresh(); // even if I just return this when the actino class have form method will always return an error
    }

    public function form()
    {
        $this->select('status', __('Status'))
            ->options(['Belum-dikembalikan' => 'Belum dikembalikan', 'Sudah-dikembalikan' => 'Sudah dikembalikan', 'Hilang/rusak' => 'Hilang/rusak'])
            ->default('Belum-dikembalikan');
    }

    public function html()
    {
        return <<<HTML
          <a class='change-status-page btn btn-sm btn-warning me-1'><i class='icon-info-circle'></i>Ubah Status Massal</a>
HTML;
    }
}

Here is the example of error:
image

here is error from log

local.ERROR: OpenAdmin\Admin\Form::model(): Return value must be of type Illuminate\Database\Eloquent\Model, OpenAdmin\Admin\Actions\Interactor\Form returned {"userId":1,"exception":"[object] (TypeError(code: 0): OpenAdmin\\Admin\\Form::model(): Return value must be of type Illuminate\\Database\\Eloquent\\Model, OpenAdmin\\Admin\\Actions\\Interactor\\Form returned at F:\\freelance\\retur-revised\\vendor\\open-admin-org\\open-admin\\src\\Form.php:188)

The same thing happens to me, I have this error too, have you found a solution?
Could someone help us please?

Most likely, the Form method is not implemented in your Controller.

  protected function form()
  {
      $form = new Form(new Page());
      // minimum
      $form->text('status', __('Status'));
      // ...

      return $form;
  }