- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
public function notLessThan($attribute_name, $params)
{
$attributes = [
[
'error' => 0,
'name' => 'ingredient_1st',
'this' => $this->ingredient_1st
],
[
'error' => 0,
'name' => 'ingredient_2nd',
'this' => $this->ingredient_2nd,
],
[
'error' => 0,
'name' => 'ingredient_3rd',
'this' => $this->ingredient_3rd
],
[
'error' => 0,
'name' => 'ingredient_4th',
'this' => $this->ingredient_4th
],
[
'error' => 0,
'name' => 'ingredient_5th',
'this' => $this->ingredient_5th
],
];
$this->counter = 0;
foreach ($attributes as $key => &$attribute) { // change array element
if (empty($attribute['this']) && $this->counter < 2) {
$attribute['error'] = 1;
} else {
$this->counter++;
}
}
if ($this->counter < 2) {
foreach ($attributes as $key => $attribute) {
if ($attribute['error']) {
$this->addError($attribute['name'], 'Должно быть заполнено не менее двух полей.');
}
}
return false;
}
return true;
}
Комментарии (0) RSS
Добавить комментарий