mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-03-12 10:36:09 +03:00
master: RepeatedType added (#1387)
* master: RepeatedType added * Fix RepeatedType support
This commit is contained in:
parent
309f935763
commit
f0b1eb7849
@ -164,6 +164,28 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
|
||||
break;
|
||||
}
|
||||
|
||||
if ('password' === $blockPrefix) {
|
||||
$property->setType('string');
|
||||
$property->setFormat('password');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ('repeated' === $blockPrefix) {
|
||||
$property->setType('object');
|
||||
$property->setRequired([$config->getOption('first_name'), $config->getOption('second_name')]);
|
||||
$subType = $config->getOption('type');
|
||||
|
||||
foreach (['first', 'second'] as $subField) {
|
||||
$subName = $config->getOption($subField.'_name');
|
||||
$subForm = $this->formFactory->create($subType, null, array_merge($config->getOption('options'), $config->getOption($subField.'_options')));
|
||||
|
||||
$this->findFormType($subForm->getConfig(), $property->getProperties()->get($subName));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ('collection' === $blockPrefix) {
|
||||
$subType = $config->getOption('entry_type');
|
||||
$subOptions = $config->getOption('entry_options');
|
||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
@ -27,5 +29,10 @@ class DummyType extends AbstractType
|
||||
$builder->add('foz', ChoiceType::class, ['choices' => ['male', 'female'], 'multiple' => true]);
|
||||
$builder->add('baz', CheckboxType::class, ['required' => false]);
|
||||
$builder->add('bey', IntegerType::class, ['required' => false]);
|
||||
$builder->add('password', RepeatedType::class, [
|
||||
'type' => PasswordType::class,
|
||||
'first_name' => 'first_field',
|
||||
'required' => true
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -293,8 +293,22 @@ class FunctionalTest extends WebTestCase
|
||||
'bey' => [
|
||||
'type' => 'integer',
|
||||
],
|
||||
'password' => [
|
||||
'type' => 'object',
|
||||
'required' => ['first_field', 'second'],
|
||||
'properties' => [
|
||||
'first_field' => [
|
||||
'type' => 'string',
|
||||
'format' => 'password',
|
||||
],
|
||||
'required' => ['foo', 'foz'],
|
||||
'second' => [
|
||||
'type' => 'string',
|
||||
'format' => 'password',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'required' => ['foo', 'foz', 'password'],
|
||||
], $this->getModel('DummyType')->toArray());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user