Development

Changeset 10382

You must first sign up to be able to contribute.

Changeset 10382

Show
Ignore:
Timestamp:
07/21/08 09:42:31 (1 year ago)
Author:
dwhittle
Message:

1.2: fixed sfValidatorPropelUnique assumes column name is used in form (closes #3960)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/plugins/sfPropelPlugin/lib/propel/validator/sfValidatorPropelUnique.class.php

    r9666 r10382  
    4444   *  * column:             The unique column name in Propel field name format (required) 
    4545   *                        If the uniquess is for several columns, you can pass an array of field names 
     46   *  * field               Field name used by the form, other than the column name 
    4647   *  * primary_key:        The primary key column name in Propel field name format (optional, will be introspected if not provided) 
    4748   *                        You can also pass an array if the table has several primary keys 
     
    5556    $this->addRequiredOption('model'); 
    5657    $this->addRequiredOption('column'); 
     58    $this->addOption('field', null); 
    5759    $this->addOption('primary_key', null); 
    5860    $this->addOption('connection', null); 
     
    7678      $this->setOption('column', array($this->getOption('column'))); 
    7779    } 
     80     
     81    if (!is_array($field = $this->getOption('field'))) 
     82    { 
     83      $this->setOption('field', $field ? array($field) : array()); 
     84    } 
     85    $fields = $this->getOption('field'); 
    7886 
    7987    $criteria = new Criteria(); 
    80     foreach ($this->getOption('column') as $column) 
     88    foreach ($this->getOption('column') as $i => $column) 
    8189    { 
    8290      $colName = call_user_func(array($this->getOption('model').'Peer', 'translateFieldName'), $column, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME); 
    8391 
    84       $criteria->add($colName, $values[$column]); 
     92      $criteria->add($colName, $values[isset($fields[$i]) ? $fields[$i] : $column]); 
    8593    } 
    8694 

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.