简体   繁体   English

没有树枝的硅胶形式

[英]silex form without twig

I'm using silex with a legacy application with a lot of smarty templates and also want to use the Form Provider, but the documentation has only an example to use this with Twig. 我正在将Silex与具有许多smarty模板的旧版应用程序一起使用,并且还想使用Form Provider,但是文档中只有一个示例可用于Twig。

Does anyone has a small example how to render the Form to a variable that can then be displayed in a smarty template 有没有人有一个小例子,如何将表单呈现为变量,然后可以在智能模板中显示

my understanding is, that you can not render a form only by the symfony form classes. 我的理解是,您不能仅通过symfony表单类来呈现表单。 Those classes do not have the functionality to render the form. 这些类不具有呈现表单的功能。 You need some templates that do the rendering. 您需要一些用于渲染的模板。 Those templates can be PHP or Twig. 这些模板可以是PHP或Twig。 Here is a example how to get the Form as HTML which you could then pass to the smarty template: 这是一个示例,如何将表单获取为HTML,然后可以将其传递给smarty模板:

$html .= $silex['twig']->render('template.twig', array(
        'form'         => $form->createView
    ));

$smarty->assign('form_html',$html);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM