open-admin-org / open-admin

open-admin forked from z-song/laravel-ladmin. Removing jquery, now based on Bootstrap5, vanilla JS
https://open-admin.org
MIT License
259 stars 75 forks source link

Error when try to use Grid Tools action #177

Open uluumbch opened 5 months ago

uluumbch commented 5 months ago

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)
Tech-Loyal commented 1 month ago

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

Ladel commented 1 month ago

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;
  }