Symfony: Application-specific form classes?
According to Symfony doc's and tutorials, it appears that Form classes are only to be put here:
/%SF_BASE_DIR%/lib/form/
But what if your site h开发者_开发百科as multiple applications (frontend, backend, etc) and you need a form class only for one of those applications? Is there any specific place to put the form class under your application directory where it will autoload? I tried the following but it didn't autoload:
/%SF_BASE_DIR%/apps/backend/lib/
/%SF_BASE_DIR%/apps/backend/lib/form/
I know that you can alter what directories are autoloaded, but I'm trying to find out if there are just some default spots in the application directory that it should go in. If there is, the doc's don't seem to make it clear, at least that I can see...
This could work for you.
In cases where I have app/module-specific forms that were distinctly different than the default, but wanted to keep the regular form class intact (because I use it in the backend), I put them inside the relevant module's directory, such as /%SF_BASE_DIR%/apps/frontend/modules/xyz/form/
They don't autoload, but there's only a single file that needs them. I just put a single require_once at the top of that module's action class, such as:
# apps/frontend/modules/xyz/actions/actions.class.php
require_once dirname(__FILE__).'/../form/FrontendXyzForm.class.php';
class xyzActions extends sfActions {
...
精彩评论