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'); $snippets = $baseForm->getSnippetsToRedraw(); if ($this->getPresenter()->isAjax() && $snippets) { foreach ($snippets as $snippet) { $this->getPresenter()->redrawControl($snippet); } $this->getPresenter()->redrawControl('sidePanel'); $this->getPresenter()->redrawControl('flashes'); } else { $this->getPresenter()->redirect('this'); } }); return $baseForm; } public function setSize(SidePanelSize $size): self { $this->size = $size; return $this; } public function setCloseConfirm(string $closeConfirm): static { $this->closeConfirm = $closeConfirm; return $this; } }