Symfony version: 3.1.3 Database: MySQL
I have the users table and it has a column as roles(LongText-DC2Type:array).
In my controller I have
EDIT #2
I looked at my own code, and I gave you the wrong information. Change it to the following. Notice the way you get the role from the form is incorrect, use the below solution. I'm fairly certain this will work for you.
->add('roles', ChoiceType::class, array(
'attr' => array(
'class' => 'form-control',
'style' => 'margin:5px 0;'),
'choices' => array(
'Teacher' => 0,
'Student' => 1,
'Parent' => 2,
),
))
if( $form->isSubmitted() && $form->isValid() ){
// some other codes
$role = $form->get('roles')->getData();
...
@dragoste made a correct statement in that you should have first tried some troubleshooting before posting the question. Also you can search online for answers as well. There are a lot of Symfony examples available.