Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony2 - array to string conversion error
    primarykey
    data
    text
    <p>I've read the other subjects but it doesn't solve my problem so:</p> <p>I've got this </p> <pre><code>-&gt;add('role', 'choice', array( 'label' =&gt; 'I am:', 'mapped' =&gt; true, 'expanded' =&gt; true, 'multiple' =&gt; false, 'choices' =&gt; array( 'ROLE_NORMAL' =&gt; 'Standard', 'ROLE_VIP' =&gt; 'VIP', ) )) </code></pre> <p>And whatever I do, I get this error:</p> <pre><code>Notice: Array to string conversion in C:\xampp\htdocs\xxx\vendor\symfony\symfony \src\Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList.php line 458 </code></pre> <p>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?</p> <p>// EDIT</p> <p>Full stack trace:</p> <pre><code>in C:\xampp\htdocs\xxx\vendor\symfony\symfony\src\Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList.php at line 458 - */ protected function fixIndex($index) { if (is_bool($index) || (string) (int) $index === (string) $index) { return (int) $index; } at ErrorHandler -&gt;handle ('8', 'Array to string conversion', 'C:\xampp\htdocs \xxx\vendor\symfony\symfony\src\Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList.php', '458', array('index' =&gt; array())) in C:\xampp\htdocs\xxx\vendor\symfony\symfony\src\Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList.php at line 458 + at ChoiceList -&gt;fixIndex (array()) in C:\xampp\htdocs\xxx\vendor\symfony\symfony\src\Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList.php at line 476 + at ChoiceList -&gt;fixIndices (array(array())) in C:\xampp\htdocs\xxx\vendor\symfony\symfony\src\Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList.php at line 152 + at SimpleChoiceList -&gt;fixChoices (array(array())) in C:\xampp\htdocs\xxx\vendor\symfony\symfony\src\Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList.php at line 204 + at ChoiceList -&gt;getIndicesForChoices (array(array())) in C:\xampp\htdocs\xxx\vendor\symfony\symfony\src\Symfony\Component\Form\Extension\Core\DataTransformer\ChoiceToBooleanArrayTransformer.php at line 63 + at ChoiceToBooleanArrayTransformer -&gt;transform (array()) in C:\xampp\htdocs\xxx\vendor\symfony\symfony\src\Symfony\Component\Form\Form.php at line 1019 + at Form -&gt;normToView (array()) in C:\xampp\htdocs\xxx\vendor\symfony\symfony\src\Symfony\Component\Form\Form.php at line 332 + at Form -&gt;setData (array()) in C:\xampp\htdocs\xxx\vendor\symfony\symfony\src\Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper.php at line 59 + at PropertyPathMapper -&gt;mapDataToForms (object(User), object(RecursiveIteratorIterator)) in C:\xampp\htdocs\xxx\vendor\symfony\symfony\src\Symfony\Component\Form\Form.php at line 375 + at Form -&gt;setData (object(User)) in C:\xampp\htdocs\xxx\vendor\friendsofsymfony\user-bundle\FOS\UserBundle\Controller\RegistrationController.php at line 49 + at RegistrationController -&gt;registerAction (object(Request)) at call_user_func_array (array(object(RegistrationController), 'registerAction'), array(object(Request))) in C:\xampp\htdocs\xxx\app\bootstrap.php.cache at line 2770 + at HttpKernel -&gt;handleRaw (object(Request), '1') in C:\xampp\htdocs\xxx\app\bootstrap.php.cache at line 2744 + at HttpKernel -&gt;handle (object(Request), '1', true) in C:\xampp\htdocs\xxx\app\bootstrap.php.cache at line 2874 + at ContainerAwareHttpKernel -&gt;handle (object(Request), '1', true) in C:\xampp\htdocs\xxx\app\bootstrap.php.cache at line 2175 + at Kernel -&gt;handle (object(Request)) in C:\xampp\htdocs\xxx\web\app_dev.php at line 29 + </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload