Development

Changeset 6873

You must first sign up to be able to contribute.

Changeset 6873

Show
Ignore:
Timestamp:
01/01/08 08:02:15 (1 year ago)
Author:
fabien
Message:

fixed foreign key bug when a column is not required

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/plugins/sfPropelPlugin/data/generator/sfPropelForm/default/template/sfPropelFormGeneratedTemplate.php

    r6174 r6873  
    5555<?php endif; ?> 
    5656 
    57 <?php foreach ($this->getForeignKeyNames() as $name): ?> 
     57<?php foreach ($this->getForeignKeyNames() as $info): $name = $info[0] ?> 
    5858  public function get<?php echo $name ?>IdentifierChoices() 
    5959  { 
     
    6565    if (!isset($this-><?php echo $name ?>Choices)) 
    6666    { 
    67       $this-><?php echo $name ?>Choices = array(); 
     67      $this-><?php echo $name ?>Choices = array(<?php !$info[1] and print "'' => ''" ?>); 
    6868      foreach (<?php echo $name ?>Peer::doSelect(new Criteria(), $this->getConnection()) as $object) 
    6969      { 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php

    r6174 r6873  
    137137   * This method does not returns foreign keys that are also primary keys. 
    138138   * 
    139    * @return array An array of foreign key PHP names 
     139   * @return array An array composed of: an array of foreign key PHP names, A Boolean to indicate whether the column is required or not 
    140140   */ 
    141141  public function getForeignKeyNames() 
     
    146146      if (!$column->isPrimaryKey() && $column->isForeignKey()) 
    147147      { 
    148         $names[] = $this->getForeignTable($column)->getPhpName(); 
     148        $names[] = array($this->getForeignTable($column)->getPhpName(), $column->isNotNull()); 
    149149      } 
    150150    } 
     
    152152    foreach ($this->getManyToManyTables() as $tables) 
    153153    { 
    154       $names[] = $tables['relatedTable']->getPhpName(); 
     154      $names[] = array($tables['relatedTable']->getPhpName(), false); 
    155155    } 
    156156