Development

Changeset 6965

You must first sign up to be able to contribute.

Changeset 6965

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

fixed propel generated forms when a table has several foreign/m2m keys to the same foreign table

Files:

Legend:

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

    r6944 r6965  
    1818<?php endforeach; ?> 
    1919<?php foreach ($this->getManyToManyTables() as $tables): ?> 
    20       '<?php echo $tables['relatedTable']->getName() ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($tables['relatedTable']->getName().'_list')) ?> => new sfWidgetFormSelectMany(array('choices' => new sfCallable(array($this, 'get<?php echo $tables['relatedTable']->getPhpName() ?>Choices')))), 
     20      '<?php echo $tables['relatedTable']->getName() ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($tables['relatedTable']->getName().'_list')) ?> => new sfWidgetFormSelectMany(array('choices' => new sfCallable(array($this, 'get<?php echo $tables['middleTable']->getPhpName() ?>Choices')))), 
    2121<?php endforeach; ?> 
    2222    )); 
     
    2727<?php endforeach; ?> 
    2828<?php foreach ($this->getManyToManyTables() as $tables): ?> 
    29       '<?php echo $tables['relatedTable']->getName() ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($tables['relatedTable']->getName().'_list')) ?> => new sfValidatorChoiceMany(array('choices' => new sfCallable(array($this, 'get<?php echo $tables['relatedTable']->getPhpName() ?>IdentifierChoices')))), 
     29      '<?php echo $tables['relatedTable']->getName() ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($tables['relatedTable']->getName().'_list')) ?> => new sfValidatorChoiceMany(array('choices' => new sfCallable(array($this, 'get<?php echo $tables['middleTable']->getPhpName() ?>IdentifierChoices')))), 
    3030<?php endforeach; ?> 
    3131    )); 
     
    5555<?php endif; ?> 
    5656 
    57 <?php foreach ($this->getForeignKeyNames() as $info): $name = $info[0] ?> 
     57<?php foreach ($this->getForeignKeyNames() as $info): $name = $info[1] ?> 
    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(<?php !$info[1] and print "'' => ''" ?>); 
    68       foreach (<?php echo $name ?>Peer::doSelect(new Criteria(), $this->getConnection()) as $object) 
     67      $this-><?php echo $name ?>Choices = array(<?php !$info[2] and print "'' => ''" ?>); 
     68      foreach (<?php echo $info[0] ?>Peer::doSelect(new Criteria(), $this->getConnection()) as $object) 
    6969      { 
    7070        $this-><?php echo $name ?>Choices[$object->get<?php echo $this->getPrimaryKey()->getPhpName() ?>()] = $object->__toString(); 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php

    r6873 r6965  
    146146      if (!$column->isPrimaryKey() && $column->isForeignKey()) 
    147147      { 
    148         $names[] = array($this->getForeignTable($column)->getPhpName(), $column->isNotNull()); 
     148        $names[] = array($this->getForeignTable($column)->getPhpName(), $column->getPhpName(), $column->isNotNull()); 
    149149      } 
    150150    } 
     
    152152    foreach ($this->getManyToManyTables() as $tables) 
    153153    { 
    154       $names[] = array($tables['relatedTable']->getPhpName(), false); 
     154      $names[] = array($tables['relatedTable']->getPhpName(), $tables['middleTable']->getPhpName(), false); 
    155155    } 
    156156 
     
    241241    if (!$column->isPrimaryKey() && $column->isForeignKey()) 
    242242    { 
    243       $options[] = sprintf('\'choices\' => new sfCallable(array($this, \'get%sChoices\'))', $this->getForeignTable($column)->getPhpName()); 
     243      $options[] = sprintf('\'choices\' => new sfCallable(array($this, \'get%sChoices\'))', $column->getPhpName()); 
    244244    } 
    245245 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.