dqsot35145 2012-07-15 12:04
浏览 37
已采纳

Symfony2日期表单类型:致命错误:在非对象上调用成员函数setLenient()

thanks to Stof on IRC i know the answer now. I just wanted to share it, in case someone stumbles upon the same problem.

The problem

When you have field type datetime:

/**
 * @ORM\Column(type="datetime", name="released_at")
 */
protected $released_at;

and in form type you use date form type:

$builder
      ->add('released_at', 'date', array(
          'widget' => 'single_text',
          'format' => 'yyyy-MM-dd',
      ));

and you're getting this error:

Fatal error: Call to a member function setLenient() on a non-object in (...)\vendor\symfony\src\Symfony\Component\Form\Extension\Core\Type\DateType.php on line 64

  • 写回答

3条回答 默认 最新

  • doutui8842 2012-07-15 12:04
    关注

    The solution is

    Try this test

    <?php
    
    $formatter = new \IntlDateFormatter();
    
    if($formatter === null)
      echo 'null!';
    else
      echo 'else';
    

    If you get null, it means your php / intl version is buggy and you need to upgrade.

    In my case, I was running @ Windows 7 64bit machine, Wampserver2 with PHP 5.3.8.

    Upgradeing to PHP 5.3.10 or higher did the trick.

    Also if you are getting:

    (..path..)\StubIntlDateFormatter::setLenient() is not implemented. Please install the 'intl' extension for full localization capabilities.

    upgrade to Symfony 2.0.16.

    Cheers and once again, TYVM Stof!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata