0

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 Answers 3

2

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!

1

I have two configurations, each with a different application: - Windows 7 64bit machine, Wampserver2 with PHP 5.3.8 with Symfony 2.0.15 installed using composer - Windows 7 64bit machine, Wampserver2 with PHP 5.3.8 with Symfony 2.1-RC1 installed from zip with vendors

On the first configuration I had the error:

Fatal error: Call to a member function format() on a non-object in C:\MyProject\vendor\symfony\src\Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer.php on line 97

On the second configuration I had the error:

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

I upgraded only PHP from 5.3.8 to 5.3.13 in my WAMP2 installation using the files provided at the following place: http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/ PHP 5.3.13 (Thread Safe) + Fixed curl extensions

and it fixed the issues on both applications !

A big thanks to Anindya for his effort offering 64bits compiled version of the PHP DLL, I didn't find an other 64bits version anywhere else ! ( and as far as I have seen (I compared the version using Beyond Compare), it was his 5.3.8 64bits thread safe version included in the Wamp2 version I have ;)

Best regards, Christophe

0

This happens if you don't have correct parameteres in your php.ini... Check if you have a correct configuration of time zone in your php.ini as "Europe/Brussels" (case sensitive)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.