wuestkamp / alterable-form-bundle
Allows Symfony Forms to be altered based on YAML configuration files
Installs: 1 173
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.6
- symfony/form: ^2.8|^3.0|^4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- mockery/mockery: ^0.9.9
- phpunit/phpunit: ^5.7
- symfony/security: ^2.8|^3.0
- symfony/validator: ^2.8|^3.0
This package is not auto-updated.
Last update: 2025-05-21 12:23:15 UTC
README
This bundle lets you alter existing Symfony Forms based on yml config values. If you want to create forms dynamically from yml check out LinioIT/dynamic-form-bundle.
Installation
This plugin requires Symfony ^2.8|^3.0|^4.0
{ "require": { "wuestkamp/alterable-form-bundle": "^0.2" } }
for SF < 4.0
Add the bundle to your AppKernel.php
new Wuestkamp\AlterableFormBundle\AlterableFormBundle();
If you are using 2.8 you need to create your forms (which you want to alter) using the classname like this instead of a name string to be able to use this bundle:
$form = $this->createForm(MyForm::class, $myObject);
for SF >= 4.0
Add this to config/bundles.php
:
\Wuestkamp\AlterableFormBundle\AlterableFormBundle::class => ['all' => true],
create file config/packages/alterable_form.yml
.
Usage
Define yml configuration like this:
alterable_form: forms: Namespace\Bundle\Form\MyForm: fields: first_name: options: required: false last_name: add: false # default is true Namespace\Bundle\Form\MyOtherForm: fields: email: options: attr: {class: 'css_class'}
Tests
Git clone this repo then composer install
and ./vendor/phpunit/phpunit/phpunit -c .