Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Form] Fix min/max length guessing for numeric types (fix #3091)

  • Loading branch information...
commit 666f2601dfdb5b299eaea1259785bb998fd2d5a2 1 parent 325699f
@vicb vicb authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 Form/DoctrineOrmTypeGuesser.php
View
16 Form/DoctrineOrmTypeGuesser.php
@@ -60,6 +60,8 @@ public function guessType($class, $property)
return new TypeGuess('datetime', array(), Guess::HIGH_CONFIDENCE);
case 'date':
return new TypeGuess('date', array(), Guess::HIGH_CONFIDENCE);
+ case 'time':
+ return new TypeGuess('time', array(), Guess::HIGH_CONFIDENCE);
case 'decimal':
case 'float':
return new TypeGuess('number', array(), Guess::MEDIUM_CONFIDENCE);
@@ -71,8 +73,6 @@ public function guessType($class, $property)
return new TypeGuess('text', array(), Guess::MEDIUM_CONFIDENCE);
case 'text':
return new TypeGuess('textarea', array(), Guess::MEDIUM_CONFIDENCE);
- case 'time':
- return new TypeGuess('time', array(), Guess::HIGH_CONFIDENCE);
default:
return new TypeGuess('text', array(), Guess::LOW_CONFIDENCE);
}
@@ -105,6 +105,10 @@ public function guessMaxLength($class, $property)
if (isset($mapping['length'])) {
return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE);
}
+
+ if (in_array($ret[0]->getTypeOfField($property), array('decimal', 'float'))) {
+ return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
+ }
}
}
@@ -113,6 +117,14 @@ public function guessMaxLength($class, $property)
*/
public function guessMinLength($class, $property)
{
+ $ret = $this->getMetadata($class);
+ if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) {
+ $mapping = $ret[0]->getFieldMapping($property);
+
+ if (in_array($ret[0]->getTypeOfField($property), array('decimal', 'float'))) {
+ return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
+ }
+ }
}
protected function getMetadata($class)
Please sign in to comment.
Something went wrong with that request. Please try again.