I've read the other subjects but it doesn't solve my problem so:
I've got this
->add('role', 'choice', array(
'label' => 'I am:',
'mapped' => true,
'expanded' => true,
'multiple' => false,
'choices' => array(
'ROLE_NORMAL' => 'Standard',
'ROLE_VIP' => 'VIP',
)
))
And whatever I do, I get this error:
Notice: Array to string conversion in C:xampphtdocsxxxvendorsymfonysymfony srcSymfonyComponentFormExtensionCoreChoiceListChoiceList.php line 458
In my form type the setRole method is not even called (when I rename it to some garbage the error still occurs). Why is this happening?
// EDIT
Full stack trace:
in C:xampphtdocsxxxvendorsymfonysymfonysrcSymfonyComponentFormExtensionCoreChoiceListChoiceList.php at line 458 -
*/
protected function fixIndex($index)
{
if (is_bool($index) || (string) (int) $index === (string) $index) {
return (int) $index;
}
at ErrorHandler ->handle ('8', 'Array to string conversion', 'C:xampphtdocs xxxvendorsymfonysymfonysrcSymfonyComponentFormExtensionCoreChoiceListChoiceList.php', '458', array('index' => array()))
in C:xampphtdocsxxxvendorsymfonysymfonysrcSymfonyComponentFormExtensionCoreChoiceListChoiceList.php at line 458 +
at ChoiceList ->fixIndex (array())
in C:xampphtdocsxxxvendorsymfonysymfonysrcSymfonyComponentFormExtensionCoreChoiceListChoiceList.php at line 476 +
at ChoiceList ->fixIndices (array(array()))
in C:xampphtdocsxxxvendorsymfonysymfonysrcSymfonyComponentFormExtensionCoreChoiceListSimpleChoiceList.php at line 152 +
at SimpleChoiceList ->fixChoices (array(array()))
in C:xampphtdocsxxxvendorsymfonysymfonysrcSymfonyComponentFormExtensionCoreChoiceListChoiceList.php at line 204 +
at ChoiceList ->getIndicesForChoices (array(array()))
in C:xampphtdocsxxxvendorsymfonysymfonysrcSymfonyComponentFormExtensionCoreDataTransformerChoiceToBooleanArrayTransformer.php at line 63 +
at ChoiceToBooleanArrayTransformer ->transform (array())
in C:xampphtdocsxxxvendorsymfonysymfonysrcSymfonyComponentFormForm.php at line 1019 +
at Form ->normToView (array())
in C:xampphtdocsxxxvendorsymfonysymfonysrcSymfonyComponentFormForm.php at line 332 +
at Form ->setData (array())
in C:xampphtdocsxxxvendorsymfonysymfonysrcSymfonyComponentFormExtensionCoreDataMapperPropertyPathMapper.php at line 59 +
at PropertyPathMapper ->mapDataToForms (object(User), object(RecursiveIteratorIterator))
in C:xampphtdocsxxxvendorsymfonysymfonysrcSymfonyComponentFormForm.php at line 375 +
at Form ->setData (object(User))
in C:xampphtdocsxxxvendorfriendsofsymfonyuser-bundleFOSUserBundleControllerRegistrationController.php at line 49 +
at RegistrationController ->registerAction (object(Request))
at call_user_func_array (array(object(RegistrationController), 'registerAction'), array(object(Request)))
in C:xampphtdocsxxxappootstrap.php.cache at line 2770 +
at HttpKernel ->handleRaw (object(Request), '1')
in C:xampphtdocsxxxappootstrap.php.cache at line 2744 +
at HttpKernel ->handle (object(Request), '1', true)
in C:xampphtdocsxxxappootstrap.php.cache at line 2874 +
at ContainerAwareHttpKernel ->handle (object(Request), '1', true)
in C:xampphtdocsxxxappootstrap.php.cache at line 2175 +
at Kernel ->handle (object(Request))
in C:xampphtdocsxxxwebapp_dev.php at line 29 +
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…