]> git.andy128k.dev Git - ipf.git/commitdiff
fix combination of nested set and file widgets/fields
authorAndrey Kutejko <andy128k@gmail.com>
Thu, 8 Dec 2016 22:59:16 +0000 (23:59 +0100)
committerAndrey Kutejko <andy128k@gmail.com>
Thu, 8 Dec 2016 22:59:16 +0000 (23:59 +0100)
ipf/form/widget/fileinput.php
ipf/form/widget/settable.php

index 8c3743f6b1a397d5f2708391d7e8d8d992d16c05..6ecf2b20b4399dc91625fdf25d2530538a588534 100644 (file)
@@ -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;
index d5fb457603ab0c705c60f26b7edf2a29e0940e6c..d3a1e255b386d7c98102b71d4046843cb6fbca2f 100644 (file)
@@ -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)