-1

i am started to learn symfony2, Here i have some basic doubts on entity relations. Totally i have two entities 1.Admission.php and 2.Mstcity.php , just i wanna make relation between these two entities. mysql Table structure:1.admission= id, name , mst_city_id 2. mst_city = id,city_name .. just i am having simple admission form. in that form i need to load the city_name select box . the relation id is in admission table mst_city_id is foreign key of mst_city table .

admission.mst_city_id=mst_city.id ...... > need city_name by this matching

just help me to understand this process

3 Answers3

1

There's no point for me to repost here the symfony docs, so go ahead and read them HERE There are examples in the docs that show exactly what you want to do.

Sehael
  • 3,678
  • 21
  • 35
0

Assuming you have proper Associations set in place, you can just add the field with entity as widget type

$builder->add('mst_city_id', 'entity', array(
    'class' => 'BundleName:mst_city',
    'property' => 'city_name',
));
satdev86
  • 800
  • 7
  • 14
0
  1. You should check which type of relations you use -One2One, One2Many, Many2Many
  2. Define relations in mappers/annotations and check for owned side
  3. Create form types and bind data from it to entities
  4. Persist and flush entities
ishenkoyv
  • 665
  • 4
  • 9