启用intl.so扩展后表单上的PHP错误消息

启用intl.so扩展后表单上的PHP错误消息,php,frameworks,symfony,intl,Php,Frameworks,Symfony,Intl,这是我的控制器: <?php namespace Home\JoinBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Home\JoinBundle\Entity\User; class DefaultController extends Controller { public function indexAction() { $user =

这是我的控制器:

<?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()));
    }

}

奇怪的是,默认值不起作用,但请尝试一下(执行与默认值相同的操作,如中所述)


奇怪的是,默认值不起作用,但请尝试一下(执行与默认值相同的操作,如中所述)


您好,谢谢您的回复。我尝试了您的建议,收到了以下消息:(!)致命错误:在第21行的/Applications/MAMP/htdocs/Symfony/src/Home/JoinBundle/Controller/DefaultController.php中找不到类“Home\JoinBundle\Controller\IntlDateFormatter”。致命错误现在应该得到修复。我错过了IntlDateFormatter前面的\项,请参阅上面的参考。我收到一个错误,说“选项”month“不存在”因此,我将它改为“月”,然后又出现了一个致命错误。这可能与我编译的intl测试失败有关吗?我在编译后运行了一个make测试,但它失败了一些测试。Symfony停止要求我安装并启用扩展,因此我认为一切正常。可捕获的致命错误:参数1传递给Symfony\Component\Form\Extension\Core\ChoiceList\MonthChoiceList::\uu construct()必须是第53行的IntlDateFormatter实例,为空,在/Applications/MAMP/htdocs/Symfony/vendor/Symfony/src/Symfony/Component/Form/Extension/Core/Type/DateType.php中调用,并在/Applications/MAMP/htdocs/Symfony/vendor/Symfony/Component/Form/Extension/Core/ChoiceList/MonthChoiceList.php第24I行中定义,我刚刚编辑了code,如果这不起作用,我将查看是否可以在本地计算机上复制错误。您好,谢谢您的回复。我尝试了您的建议,并收到以下消息:(!)致命错误:在第21行的/Applications/MAMP/htdocs/Symfony/src/Home/JoinBundle/Controller/DefaultController.php中找不到类“Home\JoinBundle\Controller\IntlDateFormatter”。致命错误现在应该得到修复。我错过了IntlDateFormatter前面的\项,请参阅上面的参考。我收到一个错误,说“选项”month“不存在”因此,我将它改为“月”,然后又出现了一个致命错误。这可能与我编译的intl测试失败有关吗?我在编译后运行了一个make测试,但它失败了一些测试。Symfony停止要求我安装并启用扩展,因此我认为一切正常。可捕获的致命错误:参数1传递给Symfony\Component\Form\Extension\Core\ChoiceList\MonthChoiceList::\uu construct()必须是第53行的IntlDateFormatter实例,为空,在/Applications/MAMP/htdocs/Symfony/vendor/Symfony/src/Symfony/Component/Form/Extension/Core/Type/DateType.php中调用,并在/Applications/MAMP/htdocs/Symfony/vendor/Symfony/Component/Form/Extension/Core/ChoiceList/MonthChoiceList.php第24I行中定义,我刚刚编辑了code,如果这不起作用,我将查看是否可以在本地计算机上复制错误。
$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();