Skip to content

Commit

Permalink
Merge pull request #220 from raziel057/patch-1
Browse files Browse the repository at this point in the history
Fix for SF > 3.0 & deprecated for SF > 2.5
  • Loading branch information
webda2l committed Feb 4, 2016
2 parents b01e953 + dd1e636 commit 193a02d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions TranslationForm/TranslationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace A2lix\TranslationFormBundle\TranslationForm;

use Symfony\Component\Form\FormRegistry,
Symfony\Component\HttpKernel\Kernel,
Doctrine\Common\Persistence\ManagerRegistry,
Doctrine\Common\Util\ClassUtils;

Expand Down Expand Up @@ -148,8 +149,14 @@ public function guessMissingFieldOptions($guesser, $class, $property, $options)
$options['pattern'] = $patternGuess->getValue();
}

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

return $options;
Expand Down

0 comments on commit 193a02d

Please sign in to comment.