Skip to content

Commit

Permalink
Merge pull request #229 from tobias-93/fix-error-symfony3
Browse files Browse the repository at this point in the history
Fix error in Symfony 3.0, deprecated pattern option in 2.5
  • Loading branch information
webda2l committed Apr 11, 2016
2 parents 193a02d + 4bb7ad1 commit a04a8db
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 a04a8db

Please sign in to comment.