From 904b2fa016f9b03d3def51e31a3b62453abbab5c Mon Sep 17 00:00:00 2001 From: jaugustin Date: Thu, 13 Oct 2011 23:44:44 +0200 Subject: [PATCH] fix generate form for many-to-many relation, use isCrossRef information to prevent wrong generation --- lib/generator/sfPropelFormGenerator.class.php | 4 ++++ lib/generator/sfPropelGenerator.class.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/generator/sfPropelFormGenerator.class.php b/lib/generator/sfPropelFormGenerator.class.php index 9e426f5da..6788b7a3b 100644 --- a/lib/generator/sfPropelFormGenerator.class.php +++ b/lib/generator/sfPropelFormGenerator.class.php @@ -125,6 +125,10 @@ public function getManyToManyTables() // go through all tables to find m2m relationships foreach ($this->dbMap->getTables() as $tableName => $table) { + if (!$table->isCrossRef()) { + continue; + } + foreach ($table->getColumns() as $column) { if ($column->isForeignKey() && $column->isPrimaryKey() && $this->table->getClassname() == $this->getForeignTable($column)->getClassname()) diff --git a/lib/generator/sfPropelGenerator.class.php b/lib/generator/sfPropelGenerator.class.php index 4b6e3fec5..4ab236a98 100644 --- a/lib/generator/sfPropelGenerator.class.php +++ b/lib/generator/sfPropelGenerator.class.php @@ -73,6 +73,10 @@ public function getManyToManyTables() // load this table's relations and related tables $table->getRelations(); + if (!$table->isCrossRef()) { + continue; + } + foreach ($table->getColumns() as $column) { if ($column->isForeignKey() && $column->isPrimaryKey() && $this->getTableMap()->getClassname() == $this->dbMap->getTable($column->getRelatedTableName())->getClassname())