Development

Changeset 8508

You must first sign up to be able to contribute.

Changeset 8508

Show
Ignore:
Timestamp:
04/17/08 19:39:15 (2 years ago)
Author:
fabien
Message:

changed form field name to only use PHP names (converted to the underscore notation) instead of column names - you need to generate your forms with propel:build-forms (closes #3278)

Files:

Legend:

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

    r8387 r8508  
    55 * 
    66 * @package    form 
    7  * @subpackage <?php echo $this->table->getName() ?> 
     7 * @subpackage <?php echo $this->underscore($this->table->getPhpName()) ?> 
    88 
    99 * @version    SVN: $Id$ 
     
    1818<?php endforeach; ?> 
    1919<?php foreach ($this->getManyToManyTables() as $tables): ?> 
    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() ?>')), 
     20      '<?php echo $this->underscore($tables['middleTable']->getPhpName()) ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($this->underscore($tables['middleTable']->getPhpName()).'_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['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)), 
     29      '<?php echo $this->underscore($tables['middleTable']->getPhpName()) ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($this->underscore($tables['middleTable']->getPhpName()).'_list')) ?> => new sfValidatorPropelChoiceMany(array('model' => '<?php echo $tables['relatedTable']->getPhpName() ?>', 'required' => false)), 
    3030<?php endforeach; ?> 
    3131    )); 
    3232 
    33     $this->widgetSchema->setNameFormat('<?php echo $this->table->getName() ?>[%s]'); 
     33    $this->widgetSchema->setNameFormat('<?php echo $this->underscore($this->table->getPhpName()) ?>[%s]'); 
    3434 
    3535    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); 
     
    6161 
    6262<?php foreach ($this->getManyToManyTables() as $tables): ?> 
    63     if (isset($this->widgetSchema['<?php echo $tables['middleTable']->getName() ?>_list'])) 
     63    if (isset($this->widgetSchema['<?php echo $this->underscore($tables['middleTable']->getPhpName()) ?>_list'])) 
    6464    { 
    6565      $values = array(); 
     
    6969      } 
    7070 
    71       $this->setDefault('<?php echo $tables['middleTable']->getName() ?>_list', $values); 
     71      $this->setDefault('<?php echo $this->underscore($tables['middleTable']->getPhpName()) ?>_list', $values); 
    7272    } 
    7373 
     
    9292    } 
    9393 
    94     if (!isset($this->widgetSchema['<?php echo $tables['middleTable']->getName() ?>_list'])) 
     94    if (!isset($this->widgetSchema['<?php echo $this->underscore($tables['middleTable']->getPhpName()) ?>_list'])) 
    9595    { 
    9696      // somebody has unset this widget 
     
    107107    <?php echo $tables['middleTable']->getPhpName() ?>Peer::doDelete($c, $con); 
    108108 
    109     $values = $this->getValue('<?php echo $tables['middleTable']->getName() ?>_list'); 
     109    $values = $this->getValue('<?php echo $this->underscore($tables['middleTable']->getPhpName()) ?>_list'); 
    110110    if (is_array($values)) 
    111111    { 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php

    r8484 r8508  
    365365    foreach ($this->getManyToManyTables() as $tables) 
    366366    { 
    367       if (($m = strlen($tables['middleTable']->getName().'_list')) > $max) 
     367      if (($m = strlen($this->underscore($tables['middleTable']->getPhpName()).'_list')) > $max) 
    368368      { 
    369369        $max = $m; 
     
    423423  { 
    424424    return call_user_func(array($this->table->getPhpName().'Peer', 'getI18nModel')); 
     425  } 
     426 
     427  public function underscore($name) 
     428  { 
     429    return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), '\\1_\\2', $name)); 
    425430  } 
    426431 

The Sensio Labs Network

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