The function isColumnsForeignKey in the sfDoctrineFormGenerator class returns true if the column is a primary key column. Therefore the wrong model name is used for the validator of the primary key column.
Fix:
/**
* Check if a column is a foreign key
*
* @param array $column
* @return boolean $bool
*/
public function isColumnForeignKey($name)
{
if ($this->isColumnPrimaryKey($name)) {
return false;
}
foreach ($this->table->getRelations() as $relation)
{
if ($relation['local'] == $name)
{
return true;
}
}
return false;
}
For my attached unit tests (PHPUnit, but you can read it like pseudo code) i extended the generator with a function to inject the model name:
public function setTable($name)
{
$this->table = Doctrine::getTable($name);
$this->modelName = $name;
}