Skip to content

Commit e47ffcf

Browse files
committed
[fix]Fix issue #2474 #2711
1 parent aa44b77 commit e47ffcf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Form/Field/HasMany.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,20 @@ public function getValidator(array $input)
133133
foreach ($rules as $column => $rule) {
134134
foreach (array_keys($input[$this->column]) as $key) {
135135
$newRules["{$this->column}.$key.$column"] = $rule;
136-
if (isset($input[$this->column][$key][$column])) {
136+
if (isset($input[$this->column][$key][$column]) &&
137+
is_array($input[$this->column][$key][$column]))
138+
{
137139
foreach ($input[$this->column][$key][$column] as $vkey => $value) {
138140
$newInput["{$this->column}.$key.{$column}$vkey"] = $value;
139141
}
140142
}
141143
}
142144
}
143145

146+
if (empty($newInput)) {
147+
$newInput = $input;
148+
}
149+
144150
return Validator::make($newInput, $newRules, $this->validationMessages, $attributes);
145151
}
146152

0 commit comments

Comments
 (0)