开发者

PHP error message on form after enabling intl.so extension

PHP error message on form after enabling intl.so extension

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜