template->size = $this->size->value; $this->template->closeConfirm = $this->closeConfirm; $this->template->setFile(__DIR__ . '/SidePanelControl.latte'); $this->template->render(); } public function setFormFactory(callable $formFactory): static { $this->formFactory = $formFactory; return $this; } /** * @throws Exception */ protected function createComponentForm(): BaseForm { /** @var BaseForm $baseForm */ $baseForm = ($this->formFactory)(); $baseForm->setOnBeforeInitForm(function (Form $form) { $url = new Url($this->getPresenter()->getHttpRequest()->getUrl()); if ($form->getEntity() && !is_callable($form->getEntity())) { $url->setQueryParameter('editId', $form->getEntity()->getId()); } $form->setAction((string) $url); }) ->setOnSuccess(function (Form $form) use ($baseForm) { $this->getPresenter()->flashMessageSuccess('fcadmin.sidePanels.control.formSaved'); $this->getPresenter()->redirect('this'); // if ($redirect = $baseForm->getRedirect($form->getEntity())) { // $this->getPresenter()->redirect($redirect[0], array_merge($redirect[1], ['redrawSidePanel' => true])); // } else { // $this->getPresenter()->redrawControl('container'); // $this->getPresenter()->redrawControl('sidePanelContainer'); // } }); return $baseForm; } public function setSize(SidePanelSize $size): self { $this->size = $size; return $this; } public function setCloseConfirm(string $closeConfirm): static { $this->closeConfirm = $closeConfirm; return $this; } }