2009/3/6 Van H Tran <tvhoang1980@yahoo.com>
I think this is not a simple question.
What I do is defining setXXXTree()|setXXXService() on the form, that when called update the correspondent input (select I guess) basing on the business service passed. This way I can test the form in isolation passing in fake services (that return, for example, fake tags for a select tags[] of an article). Then you can write a factory to build the form passing in the right services basing on the root id you define or what ever. In your controller instance the factory and tell it to build a form for you.
You don't need a factory for every form, however; one for every module is enough, that collects creation methods for all entities form.
I need to pass a variable (root categories) from controller to a form creation so that inside the form, the category tree can be generated
I am facing a problem here: How to pass the $rootCategoryId to the Form creation. I don't want to have to define a "setRootCategoryId()" and "addCategorySelectBox" functions inside the form. It does not seem so smooth, architecturally...
I think this is not a simple question.
What I do is defining setXXXTree()|setXXXService() on the form, that when called update the correspondent input (select I guess) basing on the business service passed. This way I can test the form in isolation passing in fake services (that return, for example, fake tags for a select tags[] of an article). Then you can write a factory to build the form passing in the right services basing on the root id you define or what ever. In your controller instance the factory and tell it to build a form for you.
You don't need a factory for every form, however; one for every module is enough, that collects creation methods for all entities form.
--
Giorgio Sironi
Piccolo Principe & Ossigeno Scripter
http://ossigeno.sourceforge.net
没有评论:
发表评论