symfony:表单与某些字段相互关联

时间:2012-04-26 18:59:05

标签: symfony1 doctrine symfony-1.4 symfony-forms

我有这个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 }

我想制作一个让这些字段相互关联的表单:我在下拉菜单中选择区域,然后在下一个下拉菜单中我可以在所选区域的省份之间进行选择,然后在最后一个下拉菜单中只能看到之前选定的省内城市。

我不知道如何做到这一点......你能帮我吗?

1 个答案:

答案 0 :(得分:3)

你可以使用这个插件这么有用 http://www.symfony-project.org/plugins/sfDependentSelectPlugin