Skip to content

Commit

Permalink
Fix error in Symfony 3.0, deprecated pattern option in 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-93 committed Apr 6, 2016
1 parent 193a02d commit 4bb7ad1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions TranslationForm/TranslationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,20 @@ public function guessMissingFieldOptions($guesser, $class, $property, $options)
$options['field_type'] = $typeGuess->getType();
}

if (!isset($options['pattern']) && ($patternGuess = $guesser->guessPattern($class, $property))) {
$options['pattern'] = $patternGuess->getValue();
}

if (Kernel::VERSION_ID > '20512') {
if (!isset($options['attr']['maxlength']) && ($maxLengthGuess = $guesser->guessMaxLength($class, $property))) {
$options['attr']['maxlength'] = $maxLengthGuess->getValue();
}
if (!isset($options['attr']['pattern']) && ($patternGuess = $guesser->guessPattern($class, $property))) {
$options['attr']['pattern'] = $patternGuess->getValue();
}
} else {
if (!isset($options['max_length']) && ($maxLengthGuess = $guesser->guessMaxLength($class, $property))) {
$options['max_length'] = $maxLengthGuess->getValue();
}
if (!isset($options['pattern']) && ($patternGuess = $guesser->guessPattern($class, $property))) {
$options['pattern'] = $patternGuess->getValue();
}
}

return $options;
Expand Down

0 comments on commit 4bb7ad1

Please sign in to comment.