当我点击提交按钮(POST 请求操作)时,我执行了以下代码:
public function earlySignupAction(Request $request)
{
$user = new User();
$form = $this->createFormBuilder($user)
->add('username', 'text')
->add('email', 'text')
->add('password', 'password')
->getForm();
$form->bind($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getEntityManager();
$userRepository = $em->getRepository('SiteUserBundle:User');
$userFoundByUsername = $userRepository->findOneBy(array('username' => $user->getUsername()));
if ($userFoundByUsername) {
$this->get('session')->getFlashBag()->add('notice', "Already registered!\n We will notify you soon!");
} else {
$session = $this->getRequest()->getSession();
$session->set('user', $user);
}
return $this->redirect($this->generateUrl('SiteMainBundle_signup_additional_info'));
}else{
foreach($form->getErrors() as $key => $error){
$this->get('session')->getFlashBag()->add('error', $error->getMessage());
}
}
return $this->redirect($this->generateUrl('ShopiousMainBundle_signup_fail'));
}
在树枝里面我有以下内容:
<form id="registerMiniForm" class="clearfix" action="{{ path('SiteMainBundle_early_signup') }}" method="post" {{ form_enctype(userForm) }} novalidate>
{{ form_widget(userForm.username, { 'attr': {'class': 'validate[required,minSize[3]] arvo-regular', 'placeholder': 'Username'} }) }}
{{ form_widget(userForm.password, { 'attr': {'class': 'validate[required] arvo-regular', 'placeholder': 'Password'} }) }}
{{ form_widget(userForm.email, { 'attr': {'class': 'validate[required,custom[email],ajax[ajaxEmailCall]] input', 'placeholder': 'Email'} }) }}
{{ form_rest(userForm) }}
<div class="register-wrap">
<input class="arvo-bold button" type="submit" value="Register" />
</div>
</form>
当我尝试打印 $user 变量时,我没有看到任何电子邮件,为什么?
class Site\UserBundle\Entity\User#367 (47) { protected $id => NULL protected $firstname => NULL protected $lastname => NULL protected $dni => NULL protected $birthday => NULL protected $website => NULL protected $biography => NULL protected $address => NULL protected $city => NULL protected $state => NULL protected $zipcode => NULL protected $phone => NULL protected $isFirstTimeAuthUsingFB => bool(true) protected $facebookId => NULL protected $profilePicture => NULL protected $shop => NULL protected $notification => NULL protected $shippingInfo => NULL protected $shoppingCart => NULL protected $paymentInfo => NULL private $followers => NULL private $following => NULL protected $invitedFriends => NULL protected $itemlikes => NULL protected $likeCount => int(0) protected $itemComments => NULL protected $commentCount => int(0) protected $shopTestimonials => NULL private $fullName => NULL protected $username => string(11) "alksdjasdla" protected $usernameCanonical => string(11) "alksdjasdla" protected $email => NULL protected $emailCanonical => NULL protected $enabled => bool(false) protected $salt => string(31) "jjkgwyjbnv488ccskk80wkc8gk4w080" protected $password => string(14) "lkasjdaslkdasd" protected $plainPassword => NULL protected $lastLogin => NULL protected $confirmationToken => NULL protected $passwordRequestedAt => NULL protected $groups => NULL protected $locked => bool(false) protected $expired => bool(false) protected $expiresAt => NULL protected $roles => NULL protected $credentialsExpired => bool(false) protected $credentialsExpireAt => NULL }