From: Andrey Kutejko Date: Thu, 8 Dec 2016 22:59:16 +0000 (+0100) Subject: fix combination of nested set and file widgets/fields X-Git-Tag: 0.6~41 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=27c8aa86ed6c80ba76f3e874e9393063af91adf4;p=ipf.git fix combination of nested set and file widgets/fields --- diff --git a/ipf/form/widget/fileinput.php b/ipf/form/widget/fileinput.php index 8c3743f..6ecf2b2 100644 --- a/ipf/form/widget/fileinput.php +++ b/ipf/form/widget/fileinput.php @@ -46,6 +46,8 @@ class IPF_Form_Widget_FileInput extends IPF_Form_Widget_Input { if (is_string($value) && $value) $sim = $this->currentValue($name, $value); + elseif (is_array($value) && isset($value['name'])) + $sim = $this->currentValue($name, $value['name']); else $sim = ''; @@ -58,6 +60,10 @@ class IPF_Form_Widget_FileInput extends IPF_Form_Widget_Input return null; $value = $data[$name]; + + if (isset($value['file']) && isset($value['file']['error']) && $value['file']['error'] === UPLOAD_ERR_NO_FILE) + unset($value['file']); + if (!isset($value['file']) && !isset($value['name'])) return null; return $value; diff --git a/ipf/form/widget/settable.php b/ipf/form/widget/settable.php index d5fb457..d3a1e25 100644 --- a/ipf/form/widget/settable.php +++ b/ipf/form/widget/settable.php @@ -37,7 +37,8 @@ class IPF_Form_Widget_SetTable extends IPF_Form_Widget foreach (\PFF\Arr::pop($extra_attrs, 'errors', array()) as $e) $errors = $e->meta; // TODO: merge - $value = $this->extraRows($value); + if (!$errors || !$errors->count()) + $value = $this->extraRows($value); $table = Tag::table(array('class' => 'set-widget')) ->attrs($this->attrs)