From 26adaae919edea8b0b80dc140fb3917a0544c5f6 Mon Sep 17 00:00:00 2001 From: Awilum Date: Wed, 11 Mar 2020 13:20:38 +0300 Subject: [PATCH] feat(form-plugin): add form_render twig function #408 --- site/plugins/form/twig/FormTwigExtension.php | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 site/plugins/form/twig/FormTwigExtension.php diff --git a/site/plugins/form/twig/FormTwigExtension.php b/site/plugins/form/twig/FormTwigExtension.php new file mode 100644 index 00000000..8e9d0621 --- /dev/null +++ b/site/plugins/form/twig/FormTwigExtension.php @@ -0,0 +1,49 @@ +flextype = $flextype; + } + + /** + * Returns a list of functions to add to the existing list. + * + * @return array + */ + public function getFunctions() : array + { + return [ + new Twig_SimpleFunction('form_render', [$this, 'form_render'], ['is_safe' => ['html']]) + ]; + } + + /** + * Form Render + */ + public function form_render(array $fieldset, array $values = []) : string + { + return $this->flextype->FormController->render($fieldset, $values); + } +}