jqh 4 years ago
parent
commit
409a30fdd2
3 changed files with 10 additions and 8 deletions
  1. 0 1
      resources/views/form/file.blade.php
  2. 1 1
      src/Form.php
  3. 9 6
      src/Form/Field/File.php

+ 0 - 1
resources/views/form/file.blade.php

@@ -7,7 +7,6 @@
         @include('admin::form.error')
         @include('admin::form.error')
 
 
         <input name="{{ $name }}" id="{{ $id }}" type="hidden" />
         <input name="{{ $name }}" id="{{ $id }}" type="hidden" />
-        <input name="file-{{ $name }}" type="file" style="display: none"/>
 
 
         <div class="web-uploader {{ $fileType }}">
         <div class="web-uploader {{ $fileType }}">
             <div class="queueList">
             <div class="queueList">

+ 1 - 1
src/Form.php

@@ -64,7 +64,7 @@ use Symfony\Component\HttpFoundation\Response;
  * @method Field\Html                   html($html, $label = '')
  * @method Field\Html                   html($html, $label = '')
  * @method Field\Tags                   tags($column, $label = '')
  * @method Field\Tags                   tags($column, $label = '')
  * @method Field\Icon                   icon($column, $label = '')
  * @method Field\Icon                   icon($column, $label = '')
- * @method Field\Embeds                 embeds($column, $label = '')
+ * @method Field\Embeds                 embeds($column, $label = '', Closure $callback = null)
  * @method Field\Captcha                captcha()
  * @method Field\Captcha                captcha()
  * @method Field\Listbox                listbox($column, $label = '')
  * @method Field\Listbox                listbox($column, $label = '')
  * @method Field\SelectResource         selectResource($column, $label = '')
  * @method Field\SelectResource         selectResource($column, $label = '')

+ 9 - 6
src/Form/Field/File.php

@@ -38,6 +38,13 @@ class File extends Field implements UploadFieldInterface
         $this->containerId = $this->generateId();
         $this->containerId = $this->generateId();
     }
     }
 
 
+    public function setElementName($name)
+    {
+        $this->mergeOptions(['elementName' => $name]);
+
+        return parent::setElementName($name);
+    }
+
     /**
     /**
      * @return mixed
      * @return mixed
      */
      */
@@ -174,7 +181,7 @@ class File extends Field implements UploadFieldInterface
 
 
         $this->forceOptions();
         $this->forceOptions();
         $this->formatValue();
         $this->formatValue();
-        $this->setUpScript();
+        $this->addScript();
 
 
         $this->addVariables([
         $this->addVariables([
             'fileType'      => $this->options['isImage'] ? '' : 'file',
             'fileType'      => $this->options['isImage'] ? '' : 'file',
@@ -185,7 +192,7 @@ class File extends Field implements UploadFieldInterface
         return parent::render();
         return parent::render();
     }
     }
 
 
-    protected function setUpScript()
+    protected function addScript()
     {
     {
         $newButton = trans('admin.uploader.add_new_media');
         $newButton = trans('admin.uploader.add_new_media');
         $options = JavaScript::format($this->options);
         $options = JavaScript::format($this->options);
@@ -237,10 +244,6 @@ class File extends Field implements UploadFieldInterface
             }, 250);
             }, 250);
         }
         }
         resize();
         resize();
-        
-        $('[name="file-{$this->getElementName()}"]').change(function () {
-            uploader.uploader.addFiles(this.files);
-        });
     }
     }
 })();
 })();
 JS;
 JS;