2011-05-31 54 views
1

I've attached an image of the error message I am getting. At first my date drop down select for users birthday was working fine. But I finally installed and enabled the intl extension that symfony2 was asking for and now I get that error message. Any idea what the problem could be?PHP錯誤信息使intl.so後延

這裏是我的控制器:

<?php 

namespace Home\JoinBundle\Controller; 

use Symfony\Bundle\FrameworkBundle\Controller\Controller; 
use Home\JoinBundle\Entity\User; 

class DefaultController extends Controller 
{ 
    public function indexAction() 
    { 
     $user = new User; 
     $user->fname; 
     $user->lname; 
     $user->bday; 

     $form = $this->get('form.factory') 
       ->createBuilder('form', $user) 
       ->add('fname', 'text', array('label' => 'First Name: ')) 
       ->add('lname', 'text', array('label' => 'Last Name: ')) 
       ->add('bday', 'birthday', array('input' => 'array', 'widget' => 'choice')) 
       ->getForm(); 


     return $this->render('HomeJoinBundle:Default:index.html.twig', array('form' => $form->createView())); 
    } 

} 

回答

1

很奇怪的是,默認值是不工作的,但嘗試了這一點(做同樣的。它應該是默認做在http://symfony.com/doc/current/reference/forms/types/birthday.html

$dater = new \IntlDateFormatter(); 
$form = $this->get('form.factory') 
      ->createBuilder('form', $user) 
      ->add('fname', 'text', array('label' => 'First Name: ')) 
      ->add('lname', 'text', array('label' => 'Last Name: ')) 
      ->add('bday', 'birthday', array('input' => 'array', 'widget' => 'choice', 'months' => $dater)) 
      ->getForm(); 
+0

嗨感謝響應詳細的事情我想你的建議,我得到這個消息:致命錯誤(!):類「首頁\ JoinBundle \ C ontroller \ IntlDateFormatter'找不到/Applications/MAMP/htdocs/Symfony/src/Home/JoinBundle/Controller/DefaultController.php 21行 – LondonGuy 2011-05-31 23:30:01

+0

致命錯誤現在應該修復。我錯過了IntlDateFormatter之前的\,參見上面的ref。 – Kai 2011-06-01 01:04:49

+0

我收到一個錯誤,說「該選項」月份「不存在」,所以我將其更改爲幾個月,並再次發生致命錯誤。這可能是與我編譯的國際失敗測試有關嗎?編譯完成後我進行了一次make測試,但未通過一些測試。 Symfony停止要求我安裝並啓用擴展,所以我認爲一切都很好。 – LondonGuy 2011-06-01 14:01:46