fsevestre / boolean-form-type
Boolean form type for Symfony REST APIs
Installs: 442 369
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/fsevestre/boolean-form-type
Requires
- php: >=7.2.5
- symfony/form: ^5.0 | ^6.0
Requires (Dev)
- phpunit/phpunit: ^8.5
- symfony/phpunit-bridge: ^5.0 | ^6.0
This package is auto-updated.
Last update: 2025-10-29 02:29:19 UTC
README
Boolean form type for Symfony REST APIs.
Installation
The recommended way to install this library is through Composer.
Require the fsevestre/boolean-form-type package by running the following command:
$ composer require fsevestre/boolean-form-type
This will resolve the latest stable version and install all the dependencies.
Otherwise, install the library and setup the autoloader yourself.
Usage
$builder->add('enabled', BooleanType::class);
By default, the form type use a data transformer which will transform the value to true (1, '1', true and
'true') or false (0, '0', false and 'false').
If you want to support more values, you can override the true_values and false_values form type options:
$builder ->add('enabled', BooleanType::class, array( 'true_values' => array(1, '1', true, 'true', 'on', 'yes'), 'false_values' => array(0, '0', false, 'false', 'off', 'no'), ) ) ;
Note: The form type is not intended to be displayed on a browser: use the built-in
CheckboxTypeform type provided by Symfony instead.
Tests
To setup and run tests follow these steps:
$ composer install $ bin/phpunit
Contributing
See CONTRIBUTING file.
License
This library is distributed under the MIT license.