Development

Changeset 8384

You must first sign up to be able to contribute.

Changeset 8384

Show
Ignore:
Timestamp:
04/10/08 15:59:46 (1 year ago)
Author:
fabien
Message:

fixed m2m widget/validator names in case you have several m2m relationship with the same object

Files:

Legend:

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

    r7147 r8384  
    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 sfWidgetFormPropelSelectMany(array('model' => '<?php echo $tables['relatedTable']->getPhpName() ?>')), 
     20      '<?php echo $tables['middleTable']->getName() ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($tables['middleTable']->getName().'_list')) ?> => new sfWidgetFormPropelSelectMany(array('model' => '<?php echo $tables['relatedTable']->getPhpName() ?>')), 
    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 sfValidatorPropelChoiceMany(array('model' => '<?php echo $tables['relatedTable']->getPhpName() ?>', 'required' => false)), 
     29      '<?php echo $tables['middleTable']->getName() ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($tables['middleTable']->getName().'_list')) ?> => new sfValidatorPropelChoiceMany(array('model' => '<?php echo $tables['relatedTable']->getPhpName() ?>', 'required' => false)), 
    3030<?php endforeach; ?> 
    3131    )); 
     
    6161 
    6262<?php foreach ($this->getManyToManyTables() as $tables): ?> 
    63     if (isset($this->widgetSchema['<?php echo $tables['relatedTable']->getName() ?>_list'])) 
     63    if (isset($this->widgetSchema['<?php echo $tables['middleTable']->getName() ?>_list'])) 
    6464    { 
    6565      $values = array(); 
     
    6969      } 
    7070 
    71       $this->setDefault('<?php echo $tables['relatedTable']->getName() ?>_list', $values); 
     71      $this->setDefault('<?php echo $tables['middleTable']->getName() ?>_list', $values); 
    7272    } 
    7373 
     
    8080 
    8181<?php foreach ($this->getManyToManyTables() as $tables): ?> 
    82     $this->save<?php echo $tables['relatedTable']->getPhpName() ?>List($con); 
     82    $this->save<?php echo $tables['middleTable']->getPhpName() ?>List($con); 
    8383<?php endforeach; ?> 
    8484  } 
    8585 
    8686<?php foreach ($this->getManyToManyTables() as $tables): ?> 
    87   public function save<?php echo $tables['relatedTable']->getPhpName() ?>List($con = null) 
     87  public function save<?php echo $tables['middleTable']->getPhpName() ?>List($con = null) 
    8888  { 
    8989    if (!$this->isValid()) 
     
    9292    } 
    9393 
    94     if (!isset($this->widgetSchema['<?php echo $tables['relatedTable']->getName() ?>_list'])) 
     94    if (!isset($this->widgetSchema['<?php echo $tables['middleTable']->getName() ?>_list'])) 
    9595    { 
    9696      // somebody has unset this widget 
     
    108108 
    109109    $values = $this->getValues(); 
    110     if (is_array($values['<?php echo $tables['relatedTable']->getName() ?>_list'])) 
     110    if (is_array($values['<?php echo $tables['middleTable']->getName() ?>_list'])) 
    111111    { 
    112       foreach ($values['<?php echo $tables['relatedTable']->getName() ?>_list'] as $value) 
     112      foreach ($values['<?php echo $tables['middleTable']->getName() ?>_list'] as $value) 
    113113      { 
    114114        $obj = new <?php echo $tables['middleTable']->getPhpName() ?>(); 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php

    r7614 r8384  
    364364    foreach ($this->getManyToManyTables() as $tables) 
    365365    { 
    366       if (($m = strlen($tables['relatedTable']->getName().'_list')) > $max) 
     366      if (($m = strlen($tables['middleTable']->getName().'_list')) > $max) 
    367367      { 
    368368        $max = $m; 

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.