English 中文(简体)
如何从 Symfony2 两种不同的形式获得信息并保存它们?
原标题:How to get informations from two different form in Symfony2 and save them?
  • 时间:2012-05-25 06:00:39
  •  标签:
  • symfony

事实上,我有一个表格,其中含有关于持续实体的输入。我想在其他地方创建另一种表格,其中含有更多信息,我想将所有内容从第一种形式的提交书中拯救出来。我无法以同样的形式纳入第二种输入,因为这并不是同一个观点。解决这一问题的最佳方法是什么?

提前感谢

最佳回答

这听起来很困难

我是否理解这一权利:

您在实体上拥有一些必需的信息和一些无效的补充信息。

现在有两种表格,一种是用所需信息创建实体,而另一种是用附加信息更新表格。

是这样吗?

我会尝试两件事:

  1. Default You create one FormType with all the fields and have two views which only render the required fields (for this don t use form_rest). Than do the form handling like descriped in the docs. It could be that this doesn t work with the validation.

  2. Use FormModels Under Form/Model/FormModelClass you have the two classes which only have the attributes the one form requires. The Form component interacts with them and maps all attributes to this models. When the form is submitted successfullly and valid you can manuelly map the attributes back to your orginal entity and persist it

问题回答

暂无回答




相关问题
Symfony 5, I can t start the server

I develop a symfony project and everything was fine. But since yesterday I can not launch the server: enter image description here The commands symfony server:start and symfony server:stop don t work ...

learning symfony 1.4 will be good when using symfony 2.0?

I know that the architecture is different in symfony 2.0 but im learning 1.4 right now. I wonder if this knowledge i gain about 1.4 will be usable for 2.0 in some extent or will it be a total waste ...

Is symfony 2.0 stable enough to use? [closed]

I wonder if Symfony 2.0 is stable enough to use? Because I ve never used Symfony before. It seems that Symfony 2 is much better than the previous version and I don t want to relearn/recode ...

your experience using symfony 2.0 [closed]

I m going to start a new project that s building web apps from scratch. I have been thinking about using symfony framework for this project. Should I start using symfony 2.0 or stick with 1.4 ? I ...

How to increase the session timeout in Symfony

I would like to know how to increase the session timeout in symfony. Is it enough to only adjust the symfony configuration settings or must I also configure anything in my php.ini file?

How stable or unstable is symfony 2.0? [closed]

Well, I know it s a preview, and I know it says that it s not yet ready for production, and yet I dare ask the question. I need to start building a pretty big application, which is planned to go live ...

热门标签