ite/form-bundle
ite/form-bundle is a Symfony bundle that provides reusable form components and helpers for building, validating, and rendering forms in PHP applications. It aims to reduce boilerplate and standardize common form workflows.
This is a Symfony 2-era bundle, so treat the first hour as a compatibility audit rather than a normal install.
composer.json in the repository for the exact Symfony and PHP constraints before running anything.composer require ite/form-bundle
If the package is not on Packagist under that exact name, add the VCS repository explicitly and pin a commit:
{
"repositories": [{ "type": "vcs", "url": "https://github.com/itedev/FormBundle" }],
"require": { "ite/form-bundle": "dev-master" }
}
app/AppKernel.php using the bundle class name from the repository (copy it exactly; Symfony 2 bundle class names are case-sensitive):
public function registerBundles()
{
$bundles = array(
// ...
new Ite\FormBundle\IteFormBundle(),
);
}
php app/console assets:install web --symlink
php app/console cache:clear
Then add the bundle's CSS/JS plus any required jQuery plugins (jQuery UI, file upload, etc.) to your base Twig template. Verify what landed in web/bundles/ — the directory name tells you the asset path.Form/, Resources/config/, and Resources/views/ in the repository. The form types/extensions define the options you can pass; the Twig templates define the markup and data-* attributes the JS hooks into. The README is likely thin, so the source and any tests are the real documentation.Use bundle form types as drop-in replacements. The normal workflow is to swap a core type for the bundle's type inside an existing FormType:
$builder->add('category', 'ite_autocomplete', array(
'class' => 'AppBundle:Category',
'route' => 'category_autocomplete',
));
Exact type names and option keys must come from the bundle's Form/Type classes — do not assume them from the README.
Prefer form type extensions over rewriting types. If you want to keep standard Symfony types and add the bundle's behavior, register a FormTypeExtension or use the bundle's extension services. This keeps your form definitions portable if you later remove the bundle.
Wire AJAX-backed fields to a small JSON controller. For autocomplete/remote-source widgets, create a dedicated route that returns JsonResponse and point the form type option at it. Keep the endpoint narrow: accept a query string, apply your own authorization and query limits, and return only the fields the widget needs.
Handle collections with prototypes. For dynamic add/remove rows, render the collection with allow_add/allow_delete and let the bundle's JS bind to the prototype. In your controller, validate the submitted collection as normal — client-side add/remove must not bypass server-side validation.
$builder->add('items', 'collection', array(
'type' => 'app_item',
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
'by_reference' => false,
));
Centralize JS options through bundle config. Put shared settings (selectors, plugin defaults, route names) in config.yml under the bundle's config key rather than scattering them across templates. If the bundle exposes services, override or decorate them in your application's service config instead of editing vendor files.
Customize via Twig form themes. Override the bundle's form theme blocks in app/Resources/views/Form/ or a project-specific theme. This is the safest extension point for markup changes because it survives Composer updates better than editing vendor/.
Test at two levels. Use functional tests to assert the form renders and submits correctly (including the data-* attributes and route options). Use a browser test (Selenium/PhantomJS in the Symfony 2 era) for the JS behavior, because unit tests will not catch plugin initialization failures.
services.xml, and namespace. A failed AppKernel registration or a missing service ID is the most common first-hour problem.web/bundles/<bundle>/ exists, that your template references the correct path, and that you cleared the cache. In dev, disable asset combining/minification while debugging.setDefaultOptions/configureOptions method to see supported keys. Passing an unsupported option throws an InvalidOptionsException at form build time — useful as a fast feedback loop.data-* attributes and classes the Twig template emits, then check the browser console for the plugin's initialization call. If the markup is right but the widget is dead, it is almost always a JS dependency or load-order issue.How can I help you explore Laravel packages today?