From: Andrey Kutejko Date: Sun, 29 Dec 2013 13:08:38 +0000 (+0200) Subject: empty file detection in fieldsets X-Git-Tag: 0.6~217 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=d7995d4c3a3d3730769dcc07b4010bb88077103d;p=ipf.git empty file detection in fieldsets --- 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;