mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-08 18:49:26 +03:00
Removed dublicated constraints in Format field. Improved format for field type of form
This commit is contained in:
parent
25ac3dd92b
commit
46bae14425
@ -260,7 +260,11 @@ class FormTypeParser implements ParserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (($choices = $config->getOption('choices')) && is_array($choices) && count($choices)) {
|
if (($choices = $config->getOption('choices')) && is_array($choices) && count($choices)) {
|
||||||
$parameters[$name]['format'] = json_encode($choices);
|
$choices = $config->getOption('choices_as_values') ?
|
||||||
|
array_values($choices) :
|
||||||
|
array_keys($choices);
|
||||||
|
sort($choices);
|
||||||
|
$parameters[$name]['format'] = '[' . join('|', $choices) . ']';
|
||||||
} elseif (($choiceList = $config->getOption('choice_list')) && $choiceList instanceof ChoiceListInterface) {
|
} elseif (($choiceList = $config->getOption('choice_list')) && $choiceList instanceof ChoiceListInterface) {
|
||||||
$choices = $this->handleChoiceListValues($choiceList);
|
$choices = $this->handleChoiceListValues($choiceList);
|
||||||
if (is_array($choices) && count($choices)) {
|
if (is_array($choices) && count($choices)) {
|
||||||
|
@ -132,7 +132,7 @@ class ValidationParser implements ParserInterface, PostParserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($vparams['format'])) {
|
if (isset($vparams['format'])) {
|
||||||
$vparams['format'] = join(', ', $vparams['format']);
|
$vparams['format'] = join(', ', array_unique($vparams['format']));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array('dataType', 'readonly', 'required', 'subType') as $reqprop) {
|
foreach (array('dataType', 'readonly', 'required', 'subType') as $reqprop) {
|
||||||
@ -278,6 +278,8 @@ class ValidationParser implements ParserInterface, PostParserInterface
|
|||||||
break;
|
break;
|
||||||
case 'Choice':
|
case 'Choice':
|
||||||
$choices = $this->getChoices($constraint, $className);
|
$choices = $this->getChoices($constraint, $className);
|
||||||
|
sort($choices);
|
||||||
|
|
||||||
$format = '[' . join('|', $choices) . ']';
|
$format = '[' . join('|', $choices) . ']';
|
||||||
if ($constraint->multiple) {
|
if ($constraint->multiple) {
|
||||||
$vparams['actualType'] = DataTypes::COLLECTION;
|
$vparams['actualType'] = DataTypes::COLLECTION;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user