I'm trying to populate a select list, with data from an entity. The options, are created correctly, and values of options are correct.
However, everytime i submit the form it always put the original value of debtorGroup, and ignores the selected value from the form
An example of the post data: (Selected debtorGroup was 3, not 2 which was the original value)
object(App\Bundle\CoreBundle\Entity\Customer)[449]
protected 'id' => int 9
private 'debtorGroup' => int 2
private 'fullName' => string 'Daniel Mensing' (length=20)
My FormBuilder code:
$form = $this->createFormBuilder($customer)
->add('debtorGroup', 'entity', array(
'mapped' => false,
'class' => 'AppCoreBundle:DebtorGroup',
'required' => true,
))
->add('fullName')
->add('companyName')
->add('address1')
->add('address2', 'text', array(
'required' => false,
))
->add('zipPostal')
->add('city')
->add('phone')
->add('email')
->getForm();
My Customer entity:
class Customer extends User
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var integer
*
* @ORM\Column(name="debtor_group", type="integer")
*/
private $debtorGroup;
/**
* @var string
*
* @ORM\Column(name="full_name", type="string", length=255)
*/
private $fullName;
/**
* @var string
*
* @ORM\Column(name="company_name", type="string", length=255)
*/
private $companyName = null;
And my DebtorGroup Entity:
class DebtorGroup
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=100)
*/
private $name;
}
Anyone has a clue whats wrong?
Thanks in advance,
/Daniel