Development

Changeset 8805

You must first sign up to be able to contribute.

Changeset 8805

Show
Ignore:
Timestamp:
05/06/08 14:16:56 (4 months ago)
Author:
fabien
Message:

added primary key column name when generating validator for foreign keys (so now this information is build at compilation instead of at runtime)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php

    r8804 r8805  
    334334    if ($column->isForeignKey()) 
    335335    { 
    336       $options[] = sprintf('\'model\' => \'%s\'', $this->getForeignTable($column)->getPhpName()); 
     336      $map = call_user_func(array($this->getForeignTable($column)->getPhpName().'Peer', 'getTableMap')); 
     337      foreach ($map->getColumns() as $primaryKey) 
     338      { 
     339        if ($primaryKey->isPrimaryKey()) 
     340        { 
     341          break; 
     342        } 
     343      } 
     344 
     345      $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $this->getForeignTable($column)->getPhpName(), strtolower($primaryKey->getColumnName())); 
    337346    } 
    338347    else if ($column->isPrimaryKey())