satboy78
satboy78

Reputation: 317

symfony: forms with some fields related each other

I've got this schema.yml

Region:
  columns:
    name: { type: string(255), notnull: true, unique: true }
  options:
    symfony: { form: false, filter: false }

Province:
  columns:
    id: { type: string(2), notnull: true, primary: true }
    name: { type: string(255), notnull: true, unique: true }
    region_id: { type: integer, notnull: true }
  relations:
    Region: { local: region_id, foreign: id, onDelete: CASCADE, foreignAlias: Provinces }
  options:
    symfony: { form: false, filter: false }

City:
  columns:
    id: { type: string(4), notnull: true, primary: true }
    name: { type: string(255), notnull: true, unique: true }
    province_id: { type: string(2), notnull: true }
    latitude: { type: decimal, scale: 6, size: 8, notnull: true }
    longitude: { type: decimal, scale: 6, size: 8, notnull: true }
  relations:
    Province: { local: province_id, foreign: id, onDelete: CASCADE, foreignAlias: Cities }
  options:
    symfony: { form: false, filter: false }

I would like to make a form that has got these fields related each other: I choose the region in a dropdown menu, then in the next dropdown menu I can choose between provinces of selected region, then in the last dropdown menu I can see only cities of the province previously selected.

I've no idea on how to do this... could you please help me?

Upvotes: 0

Views: 448

Answers (1)

Haithem Rihane
Haithem Rihane

Reputation: 394

you can use this plugin its so helpful http://www.symfony-project.org/plugins/sfDependentSelectPlugin

Upvotes: 3

Related Questions