I'm trying to add a password repeat using easy admin bundle but I'm not quite sure how to do it. I have these two properties in my entity
/**
* @var string
*
* @Assert\NotBlank()
* @Assert\Length(max="4096")
*/
private $plainPassword;
/**
* @var string
*
* @ORM\Column(type="string", length=64)
*/
private $password;
If I add a type: repeated in my config.yml file it just creates two input fields but not a Password type. I believe form should be like this.
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('email', EmailType::class)
->add('username', TextType::class)
->add('plainPassword', RepeatedType::class, array(
'type' => PasswordType::class,
'first_options' => array('label' => 'Password'),
'second_options' => array('label' => 'Repeat Password'),
)
)
->add('termsAccepted', CheckboxType::class, array(
'mapped' => false,
'constraints' => new IsTrue(),
)
);
}
I have checked the easy admin bundle documentation but I'm kinda lost how to implement it. https://github.com/javiereguiluz/EasyAdminBundle/blob/master/Resources/doc/book/7-complex-dynamic-backends.md
Thanks
Edit Okay so I extended the AdminController of
JavierEguiluz\Bundle\EasyAdminBundle\Controller\AdminController
public function createNewForm($entity, array $entityProperties) { $userForm = parent::createNewForm($entity, $entityProperties); if ($entity instanceof User) { $userForm->remove('password'); $userForm->add('plainPassword', RepeatedType::class, array( 'type' => PasswordType::class, 'first_options' => array('label' => 'Password'), 'second_options' => array('label' => 'Re-enter Password') )); } return $userForm; }
But now when I try to insert / submit the form, sql error password cannot be null.