mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-03-12 10:36:09 +03:00
Add support for boolean type for CheckboxType (#1123)
* Add support for boolean type for CheckboxType * add functional tests to checkbox form type as boolean
This commit is contained in:
parent
29ec20bda1
commit
bff1b3ba0a
@ -98,6 +98,11 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('checkbox' === $blockPrefix) {
|
||||||
|
$property->setType('boolean');
|
||||||
|
}
|
||||||
|
|
||||||
if ('collection' === $blockPrefix) {
|
if ('collection' === $blockPrefix) {
|
||||||
$subType = $config->getOption('entry_type');
|
$subType = $config->getOption('entry_type');
|
||||||
$property->setType('array');
|
$property->setType('array');
|
||||||
|
@ -13,6 +13,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Form;
|
|||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
@ -22,5 +23,6 @@ class DummyType extends AbstractType
|
|||||||
{
|
{
|
||||||
$builder->add('bar', TextType::class, ['required' => false]);
|
$builder->add('bar', TextType::class, ['required' => false]);
|
||||||
$builder->add('foo', ChoiceType::class, ['choices' => ['male', 'female']]);
|
$builder->add('foo', ChoiceType::class, ['choices' => ['male', 'female']]);
|
||||||
|
$builder->add('baz', CheckboxType::class, ['required' => false]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,6 +215,9 @@ class FunctionalTest extends WebTestCase
|
|||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'enum' => ['male', 'female'],
|
'enum' => ['male', 'female'],
|
||||||
],
|
],
|
||||||
|
'baz' => [
|
||||||
|
'type' => 'boolean'
|
||||||
|
]
|
||||||
],
|
],
|
||||||
'required' => ['foo'],
|
'required' => ['foo'],
|
||||||
], $this->getModel('DummyType')->toArray());
|
], $this->getModel('DummyType')->toArray());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user