2011-11-25 15 views
6

सिमफ़ोनी 2 के साथ फॉर्म में दिनांक फ़ील्ड का उपयोग करते समय, वे तीन अलग-अलग चयन बॉक्स में प्रदर्शित होते हैं। कुछ की तरह:Symfony2 में दिनांक फ़ील्ड के लिए महीनों को पूर्ण पाठ में कैसे प्रदर्शित करें?

dd/mm/YYYY 

हम करना चाहते हैं क्या पाठ January, February में महीने प्रदर्शित .... 1,2,3 के बजाय है ...

कैसे पूर्ण में प्रदर्शन के लिए मजबूर करने महीनों के ड्रॉपडाउन के लिए पाठ? एक छवि एफ

enter image description here

उत्तर

8

DateType वर्ग के कोड पर देखो दिखा रहा है, यह है:

संपादित करें:

$builder->add('dateOfBirth', 'birthday', array(
    'format' => 'dd - MM - yyyy', 
    'widget' => 'choice', 
    'years' => range(date('Y'), date('Y')-70) 
)); 

EDIT2: यहाँ कोड मैं अपने प्रपत्र कक्षा में उपयोग करें प्रारूप विकल्प:

$allowedFormatOptionValues = array(
      \IntlDateFormatter::FULL, 
      \IntlDateFormatter::LONG, 
      \IntlDateFormatter::MEDIUM, 
      \IntlDateFormatter::SHORT, 
     ); 

     // If $format is not in the allowed options, it's considered as the pattern of the formatter if it is a string 
     if (!in_array($format, $allowedFormatOptionValues, true)) { 
      if (is_string($format)) { 
       $defaultOptions = $this->getDefaultOptions($options); 

       $format = $defaultOptions['format']; 
       $pattern = $options['format']; 
      } else { 
       throw new CreationException('The "format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom pattern'); 
      } 
     } 

$formatter = new \IntlDateFormatter(
     \Locale::getDefault(), 
     $format, 
     \IntlDateFormatter::NONE, 
     \DateTimeZone::UTC, 
     \IntlDateFormatter::GREGORIAN, 
     $pattern 
    ); 

UPDAT ई

$builder->add('dateOfBirth', 'birthday', array(
    'format' => 'dd - MMMM - yyyy', 
    'widget' => 'choice', 
    'years' => range(date('Y'), date('Y')-70) 
)); 
+0

क्या आप इस प्रश्न में जोड़े गए कोड का उपयोग करके एक उदाहरण दे सकते हैं? –

+0

धन्यवाद, आपके त्वरित उत्तर के लिए, लेकिन मैंने पहले से ही कोशिश की है, और 'एफ' का अर्थ सिम्फनी द्वारा नहीं किया जा रहा है। –

+0

यह इसलिए होना चाहिए क्योंकि 'दिनांक() 'वास्तव में उपयोग नहीं किया जाता है। यह वर्ग: http://www.php.net/manual/en/class.intldateformatter.php का उपयोग – greg0ire

संबंधित मुद्दे