mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Merge pull request #264 from driebit/embedded-forms
Add support for embedded forms
This commit is contained in:
commit
29965ec7bb
@ -102,6 +102,12 @@ class FormTypeParser implements ParserInterface
|
|||||||
} elseif ('collection' === $type->getName()) {
|
} elseif ('collection' === $type->getName()) {
|
||||||
if (is_string($config->getOption('type')) && isset($this->mapTypes[$config->getOption('type')])) {
|
if (is_string($config->getOption('type')) && isset($this->mapTypes[$config->getOption('type')])) {
|
||||||
$bestType = sprintf('array of %ss', $this->mapTypes[$config->getOption('type')]);
|
$bestType = sprintf('array of %ss', $this->mapTypes[$config->getOption('type')]);
|
||||||
|
} else {
|
||||||
|
// Embedded form collection
|
||||||
|
$subParameters = $this->parseForm($this->formFactory->create($config->getOption('type')), $name . '[]');
|
||||||
|
$parameters = array_merge($parameters, $subParameters);
|
||||||
|
|
||||||
|
continue 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,21 @@ class FormTypeParserTest extends \PHPUnit_Framework_TestCase
|
|||||||
'description' => '',
|
'description' => '',
|
||||||
'readonly' => false
|
'readonly' => false
|
||||||
),
|
),
|
||||||
'collection_type[b]' => array(
|
'collection_type[b][][a]' => array(
|
||||||
'dataType' => 'string',
|
'dataType' => 'string',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
'description' => 'A nice description',
|
||||||
|
'readonly' => false
|
||||||
|
),
|
||||||
|
'collection_type[b][][b]' => array(
|
||||||
|
'dataType' => 'string',
|
||||||
|
'required' => true,
|
||||||
|
'description' => '',
|
||||||
|
'readonly' => false
|
||||||
|
),
|
||||||
|
'collection_type[b][][c]' => array(
|
||||||
|
'dataType' => 'boolean',
|
||||||
|
'required' => true,
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'readonly' => false
|
'readonly' => false
|
||||||
)
|
)
|
||||||
@ -83,9 +95,21 @@ class FormTypeParserTest extends \PHPUnit_Framework_TestCase
|
|||||||
'description' => '',
|
'description' => '',
|
||||||
'readonly' => false
|
'readonly' => false
|
||||||
),
|
),
|
||||||
'b' => array(
|
'b[][a]' => array(
|
||||||
'dataType' => 'string',
|
'dataType' => 'string',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
'description' => 'A nice description',
|
||||||
|
'readonly' => false
|
||||||
|
),
|
||||||
|
'b[][b]' => array(
|
||||||
|
'dataType' => 'string',
|
||||||
|
'required' => true,
|
||||||
|
'description' => '',
|
||||||
|
'readonly' => false
|
||||||
|
),
|
||||||
|
'b[][c]' => array(
|
||||||
|
'dataType' => 'boolean',
|
||||||
|
'required' => true,
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'readonly' => false
|
'readonly' => false
|
||||||
)
|
)
|
||||||
@ -103,9 +127,21 @@ class FormTypeParserTest extends \PHPUnit_Framework_TestCase
|
|||||||
'description' => '',
|
'description' => '',
|
||||||
'readonly' => false
|
'readonly' => false
|
||||||
),
|
),
|
||||||
'b' => array(
|
'b[][a]' => array(
|
||||||
'dataType' => 'string',
|
'dataType' => 'string',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
'description' => 'A nice description',
|
||||||
|
'readonly' => false
|
||||||
|
),
|
||||||
|
'b[][b]' => array(
|
||||||
|
'dataType' => 'string',
|
||||||
|
'required' => true,
|
||||||
|
'description' => '',
|
||||||
|
'readonly' => false
|
||||||
|
),
|
||||||
|
'b[][c]' => array(
|
||||||
|
'dataType' => 'boolean',
|
||||||
|
'required' => true,
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'readonly' => false
|
'readonly' => false
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user