Skip to content
Snippets Groups Projects
Commit a838d4f6 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

allow rendering of forms outside of dialog, fixes #4775

Closes #4775

Merge request studip/studip!3567
parent 60903cff
No related branches found
No related tags found
No related merge requests found
...@@ -585,7 +585,8 @@ abstract class StudipController extends Trails\Controller ...@@ -585,7 +585,8 @@ abstract class StudipController extends Trails\Controller
public function render_form(\Studip\Forms\Form $form) public function render_form(\Studip\Forms\Form $form)
{ {
$this->render_text($form->render()); \NotificationCenter::postNotification('FormWillRender', $form);
$this->render_template($form->getTemplate(), $this->layout);
} }
/** /**
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace Studip\Forms; namespace Studip\Forms;
use Flexi\Template;
class Form extends Part class Form extends Part
{ {
...@@ -495,12 +497,20 @@ class Form extends Part ...@@ -495,12 +497,20 @@ class Form extends Part
* @return string * @return string
* @throws \Flexi\TemplateNotFoundException * @throws \Flexi\TemplateNotFoundException
*/ */
public function render() public function render(string|Template $layout = null)
{ {
\NotificationCenter::postNotification('FormWillRender', $this); \NotificationCenter::postNotification('FormWillRender', $this);
return $this->getTemplate()->render([], $layout);
}
/**
* Returns the template used for this form populated with this form object.
*/
public function getTemplate(): Template
{
$template = $GLOBALS['template_factory']->open('forms/form'); $template = $GLOBALS['template_factory']->open('forms/form');
$template->form = $this; $template->form = $this;
return $template->render(); return $template;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment