|
Revision 11612, 1.0 kB
(checked in by nicolas, 4 years ago)
|
[1.1] fixed sfValidatorChoice and sfValidatorChoiceMany can evaluate strings as int using PHP in_array() function (closes #4212)
|
- Property svn:mime-type set to
text/x-php
- Property svn:eol-style set to
native
- Property svn:keywords set to
Id
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
class sfValidatorChoiceMany extends sfValidatorChoice |
|---|
| 20 |
{ |
|---|
| 21 |
|
|---|
| 22 |
* @see sfValidatorBase |
|---|
| 23 |
*/ |
|---|
| 24 |
protected function doClean($values) |
|---|
| 25 |
{ |
|---|
| 26 |
if (!is_array($values)) |
|---|
| 27 |
{ |
|---|
| 28 |
$values = array($values); |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
$choices = $this->getOption('choices'); |
|---|
| 32 |
if ($choices instanceof sfCallable) |
|---|
| 33 |
{ |
|---|
| 34 |
$choices = $choices->call(); |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
foreach ($values as $value) |
|---|
| 38 |
{ |
|---|
| 39 |
if (!parent::inChoices($value, $choices)) |
|---|
| 40 |
{ |
|---|
| 41 |
throw new sfValidatorError($this, 'invalid', array('value' => $value)); |
|---|
| 42 |
} |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
return $values; |
|---|
| 46 |
} |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|