mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Add support for nested form types
This commit is contained in:
parent
15a4558277
commit
83c91a3d9d
@ -55,12 +55,22 @@ class FormTypeParser
|
||||
if (is_string($type) && class_exists($type)) {
|
||||
$type = new $type();
|
||||
}
|
||||
|
||||
$form = $this->formFactory->create($type);
|
||||
|
||||
return $this->parseForm($form);
|
||||
}
|
||||
|
||||
private function parseForm($form, $prefix = null)
|
||||
{
|
||||
$parameters = array();
|
||||
foreach ($form as $name => $child) {
|
||||
$config = $child->getConfig();
|
||||
|
||||
if ($prefix) {
|
||||
$name = sprintf('%s[%s]', $prefix, $name);
|
||||
}
|
||||
|
||||
$bestType = '';
|
||||
for ($type = $config->getType(); null !== $type; $type = $type->getParent()) {
|
||||
if (isset($this->mapTypes[$type->getName()])) {
|
||||
@ -68,6 +78,17 @@ class FormTypeParser
|
||||
}
|
||||
}
|
||||
|
||||
if ('' === $bestType) {
|
||||
if ($type = $config->getType()) {
|
||||
if ($type = $type->getInnerType()) {
|
||||
$subForm = $this->formFactory->create($type);
|
||||
$parameters = array_merge($parameters, $this->parseForm($subForm, $name));
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$parameters[$name] = array(
|
||||
'dataType' => $bestType,
|
||||
'required' => $config->getRequired(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user