我試圖使用簡單的管理包添加密碼重複,但我不太確定如何執行此操作。 我有這兩個屬性在我的實體如何在簡單的管理包中添加重複類型字段
/**
* @var string
*
* @Assert\NotBlank()
* @Assert\Length(max="4096")
*/
private $plainPassword;
/**
* @var string
*
* @ORM\Column(type="string", length=64)
*/
private $password;
如果我添加類型:在我config.yml文件重複,它只是創建了兩個輸入字段,但沒有密碼類型。我相信形式應該是這樣的。
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(),
)
);
}
我已經檢查了簡單的管理軟件包文檔,但我有點失落如何實現它。 https://github.com/javiereguiluz/EasyAdminBundle/blob/master/Resources/doc/book/7-complex-dynamic-backends.md
感謝
編輯 好了,所以我延長
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; }
的AdminController但現在,當我嘗試插入/提交表單,SQL錯誤密碼不能空值。
財產 'passwordEnClaro' 配置工作爲symfony1.2 2.8 *和爲了使symfony的3.2工作*工作' - {屬性: 'plainPassword',輸入: '密碼',標籤: '密碼',幫助:'密碼必須至少有8個字符',type_options:{required:false}}' –
應該有一些問題,因爲使用symfony 4 beta 1它說無法加載類型「密碼」 – Leggy7