KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Call undefined formatUsing() method #3459

Open Wayland Games opened this topic on 6 days ago - 2 comments

Wayland Games commented 6 days ago

Hi there,

I have an exception when trying to edit a user in the admin panel:

Message: Call undefined formatUsing() method Line: 23 File: /var/www/pulse/vendor/koolreport/dashboard/TMagicMethod.php

Here is my class for the user resource

class WBIUser extends Resource
{
	protected function onCreated(): void
	{
		$this->manageTable('wbi_user')
			->inSource(WAYLAMPToolboxDB::class);
		$this->listScreen()
			->searchBox()
			->enabled(true)
			->placeHolder('Search Users');
		$this->listScreen()
			->adminTable()
			->tableStriped(true);
	}

	protected function actions(): array
	{
		return [
			UpdateAction::create(),
			DeleteAction::create()
		];
	}

	protected function fields()
	{
		return [
			ID::create('id')
				->searchable(false)
				->sortable(false)
				->showOnIndex(false)
				->showOnCreate(false)
				->showOnUpdate(false),
			Text::create('name')
				->searchable(true)
				->sortable(true)
				->validators([
					RequiredFieldValidator::create(),
				]),
			Password::create('password')
				->searchable(false)
				->sortable(false)
				->showOnIndex(false)
				->maskedText("********")
				->processValueToDatabase(function ($password) {
					return md5($password);
				})
				->validators([
					RequiredFieldValidator::create(),
				]),
			Image::create('avatar')
				->accept(['jpg'])
				->saveToFolder('assets/avatars')
				->formatUsing(function ($filename) {
					return "assets/avatars/$filename";
				})
		];
	}
}

And here's the full trace:

#0: /var/www/pulse/vendor/koolreport/dashboard/admin/screens/TAutoInputWidget.php Line 23 : __call(null) #1: /var/www/pulse/vendor/koolreport/dashboard/admin/screens/UpdateScreen.php Line 149 : autoInputWidgetForField(null) #2: /var/www/pulse/vendor/koolreport/dashboard/admin/screens/Screen.php Line 58 : content(null) #3: /var/www/pulse/vendor/koolreport/dashboard/admin/screens/Screen.php Line 65 : layout(null) #4: /var/www/pulse/vendor/koolreport/dashboard/admin/screens/Screen.php Line 31 : getLayout(null) #5: /var/www/pulse/vendor/koolreport/dashboard/Dashboard.php Line 250 : getWidgets(null) #6: /var/www/pulse/vendor/koolreport/dashboard/Dashboard.php Line 117 : getWidgets(null) #7: /var/www/pulse/vendor/koolreport/dashboard/TEvent.php Line 32 : beforeOnInit(null) #8: /var/www/pulse/vendor/koolreport/dashboard/PropModel.php Line 35 : fireEvent(null) #9: /var/www/pulse/vendor/koolreport/dashboard/Dashboard.php Line 268 : init(null) #10: /var/www/pulse/vendor/koolreport/dashboard/pages/Main.php Line 175 : handle(null) #11: /var/www/pulse/vendor/koolreport/dashboard/Application.php Line 380 : handle(null) #12: /var/www/pulse/vendor/koolreport/dashboard/Application.php Line 289 : handle(null) #13: /var/www/pulse/index.php Line 21 : run(null)

I'm on Koolreport Dashboard version 4.8.3 and Koolreport Pro 6.6.3

Thanks in advance! Sam

Sebastian Morales commented 6 days ago

I can confirm this is a bug of Image field when editing an Admin panel. We will fix it in the next version of Dashboard. Meanwhile, you could apply the following quick fix by opening the file /var/www/pulse/vendor/koolreport/dashboard/admin/screens/TAutoInputWidget.php and replace this line:

                    ->resolveUrl($this->formatUsing())

with this one:

                    ->resolveUrl($field->formatUsing())
Wayland Games commented 6 days ago

Excellent, that works! Thanks for the swift response Sebastian. I'll wait the next version of the dashboard :)

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
solved

None