From d7995d4c3a3d3730769dcc07b4010bb88077103d Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sun, 29 Dec 2013 15:08:38 +0200 Subject: [PATCH] empty file detection in fieldsets --- ipf/admin/modelinline.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ipf/admin/modelinline.php b/ipf/admin/modelinline.php index 6693b86..4ac7dc3 100644 --- a/ipf/admin/modelinline.php +++ b/ipf/admin/modelinline.php @@ -66,7 +66,9 @@ abstract class IPF_Admin_ModelInline if (!$form->isValid()) { $empty = true; foreach ($form->data as $k => $v) { - if ($k !== 'is_remove' && $v) { + if (is_array($v) && ArrayTools::get($v, 'error') === 4) { + // empty file + } elseif ($k !== $form->prefix.'is_remove' && $v) { $empty = false; break; } @@ -140,7 +142,7 @@ abstract class IPF_Admin_ModelInline 'name' => 'is_remove', )); $del->is_del = true; - $form->fields = array_merge(array($del), $form->fields); + $form->fields = array_merge(array('is_remove' => $del), $form->fields); $form->isAdd = false; $this->formset[] = $form; @@ -162,7 +164,7 @@ abstract class IPF_Admin_ModelInline )); $del->is_del = true; - $form->fields = array_merge(array($del), $form->fields); + $form->fields = array_merge(array('is_remove' => $del), $form->fields); $form->isAdd = true; $this->formset[] = $form; -- 2.49.0