Skip to content

Instantly share code, notes, and snippets.

@pboethig
Created July 16, 2016 13:17
Show Gist options
  • Save pboethig/e2eb513ea20670121da9d7aeb78c36b0 to your computer and use it in GitHub Desktop.
Save pboethig/e2eb513ea20670121da9d7aeb78c36b0 to your computer and use it in GitHub Desktop.
<?php
namespace Check\BlogBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
class UserType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('username')
->add('email', EmailType::class,array('empty_data' => null))
->add('password',RepeatedType::class, array(
'type' => PasswordType::class,
'first_options' => array('label' => 'Password'),
'second_options' => array('label' => 'Repeat Password')))
->add('firstname')
->add('lastname')
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Check\BlogBundle\Entity\User'
));
}
public function getBlockPrefix()
{
return 'check_blogbundle_user';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment