FriendsOfSymfony/FOSUserBundle — Issue #458: expiresAt and credentialsExpireAt mandatory fields?
Author: suncat2000
Created: 2011-12-20 16:47:37+00:00
State: open

In User.orm xml fields expiresAt and credentialsExpireAt has nullable="true" attribute, but in FOS\UserBundle\Model\User methods setExpiresAt and setCredentialsExpireAt has argument $ date instance of \ DateTime.
This fields required?

I need to create a user from the form in which these fields shown, but can be not filled, then I get an exception:

Catchable Fatal Error: Argument 1 passed to ...\MyBundle\Entity\User::setExpiresAt() must be
an instance of DateTime, null given, called in
.../vendor/symfony/src/Symfony/Component/Form/Util/PropertyPath.php on line 346 and defined in
.../MyBundle/Entity/User.php line 18

can be removed type control from argument in methods:

setExpiresAt(\DateTime $date) and setCredentialsExpireAt(\DateTime $date)

like this:

public function setExpiresAt($date)
{
if($date instanceof DateTime){
$this->expiresAt = $date;
}
}

public function setCredentialsExpireAt$date)
{
if($date instanceof DateTime){
$this->expiresAt = $date;
}
}