简体   繁体   中英

PHP error message on form after enabling intl.so extension

我附上了我收到的错误消息的图像。起初,我为用户生日选择的日期下拉选择工作正常。但我最终安装并启用了 symfony2 要求的 intl 扩展,现在我收到了错误消息。知道问题可能是什么吗?

Here is my controller:

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

}

It's strange that the default value isn't working, but try this out (doing the same thing it should be doing by default as detailed in 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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM