0
我試圖用symfony2構建一個非常簡單的應用程序。Symfony2 - FOS UserBundle - 用數據從數據庫覆蓋下拉列表的覆蓋寄存器形式
我已經安裝並配置了帶有HWI Oauth2的FOS UserBundle。
這工作正常,但我想修改註冊表格,以便它有一個下拉列表,其中的數據來自我的數據庫中的數據由原則拉出。
我沒有在Symfony doc上找到任何東西。 。
有人可以提供一個建議嗎?
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))
->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))
**/**** This Works and give a dropdownlist but i want to get this list from database instead of hard coded data how can I achieve that ? *****/**
->add('status_type', 'choice', array(
'choices' => array(
'' => 'Please Select...',
'developper' => 'Android Developper',
'architect' => 'Android or Mobile Architect',
'mobile' => 'Mobile Developper',
'web and mobile' => 'Web and Mobile Developper',
)))
->add('plainPassword', 'repeated', array(
'attr' => array('class' => 'form-control'),
'type' => 'password',
'options' => array('translation_domain' => 'FOSUserBundle'),
'first_options' => array('label' => 'form.password'),
'second_options' => array('label' => 'form.password_confirmation'),
'invalid_message' => 'fos_user.password.mismatch',
))
;
}