Skip to content

Commit 2c4feab

Browse files
authored
Merge pull request #28 from Junkins/issues-27
再帰処理内にバリデーションエラーの処理を内包させた
2 parents 18d730d + c314276 commit 2c4feab

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

src/Controller/Component/MultiStepFormComponent.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -261,26 +261,6 @@ protected function mergeData()
261261
* @author ito
262262
*/
263263
private function fieldAdjustment($data)
264-
{
265-
// Entity化した際に発生した差分を吸収
266-
$data = $this->adjustmentDifference($data);
267-
$sampleEntity = $this->handleNewEntity($data);
268-
// バリデーションエラーになったフィールドをセット
269-
foreach ($sampleEntity->invalid() as $key => $value) {
270-
// ファイル形式のデータ場合、フィールドにセットしない
271-
if ($this->isFileData($value)) {
272-
continue;
273-
}
274-
$data[$key] = $value;
275-
}
276-
return $data;
277-
}
278-
279-
/**
280-
* adjustmentDifference
281-
* @author ito
282-
*/
283-
private function adjustmentDifference($data)
284264
{
285265
$adjustment = function($data) use (&$adjustment)
286266
{
@@ -319,10 +299,20 @@ private function adjustmentDifference($data)
319299
unset($data[$key]);
320300
}
321301

302+
// バリデーションエラーになったフィールドをセット
303+
foreach ($sampleEntity->invalid() as $key => $value) {
304+
// ファイル形式のデータ場合、フィールドにセットしない
305+
if ($this->isFileData($value)) {
306+
continue;
307+
}
308+
$data[$key] = $value;
309+
}
310+
322311
return $data;
323312
};
324313

325314
return $adjustment($data);
315+
326316
}
327317

328318
/**

0 commit comments

Comments
 (0)