Redirecting to a presenter with module from Nette\Application\UI\Control

Nacioszeczek
Member | 3
+
0
-

Hi, I'm trying to redirect the user from a class that extends Nette\Application\UI\Control,
however I wouldn't put the redirect I get error that either the component name is invalid or that it doesn't exist.
Component name must be non-empty alphanumeric string, '' given. or Component with name 'Admin' does not exist.
function code is:

public function handleFormSelect(Form $form, $data): void
	{
		bdump($this->mapping->getDestination()); // correct
		bdump($this->mapping->getParameterName()); // correct
		//              |-- :Admin:Server:viewEdit ----|  |-- server_id --------------------|
		$this->redirect($this->mapping->getDestination(), [$this->mapping->getParameterName() => $data['id']]);
	}

Any help would be greatly appreciated ^^

Marek Bartoš
Nette Blogger | 1171
+
+2
-

Redirects in components work differently than redirects in presenters, they are designed purely for scope of component. You can use $this->presenter->redirect() instead.
Ideally passed as a callable from constructor, so every presenter must set the redirect and component is independent of in which presenter is used
The difference is described here: https://doc.nette.org/…eating-links#…

Last edited by Mabar (2021-02-18 14:30)