From dd1e6368a336adc1033da19a7071f9d77713ff89 Mon Sep 17 00:00:00 2001 From: Thomas Lallement Date: Thu, 28 Jan 2016 16:48:45 +0100 Subject: [PATCH] Fix for SF > 3.0 & deprecated for SF > 2.5 --- TranslationForm/TranslationForm.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/TranslationForm/TranslationForm.php b/TranslationForm/TranslationForm.php index 7963dae..50e11ea 100644 --- a/TranslationForm/TranslationForm.php +++ b/TranslationForm/TranslationForm.php @@ -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; @@ -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;