Browse Source

Add accept property for file selection fields

Visman 4 years ago
parent
commit
6cefed419e
2 changed files with 8 additions and 1 deletions
  1. 7 0
      app/Models/Pages/Profile/Edit.php
  2. 1 1
      app/templates/layouts/form.forkbb.php

+ 7 - 0
app/Models/Pages/Profile/Edit.php

@@ -12,6 +12,12 @@ use function \ForkBB\__;
 
 class Edit extends Profile
 {
+    /**
+     * Паттерн для доступных к загрузке типов файлов
+     * @var string
+     */
+    protected $accept = 'image/*';
+
     /**
      * Подготавливает данные для шаблона редактирования профиля
      *
@@ -349,6 +355,7 @@ class Edit extends Profile
                     \ForkBB\num($this->c->config->o_avatars_size),
                     \ForkBB\size($this->c->config->o_avatars_size)
                 ),
+                'accept'  => $this->accept,
             ];
         }
         $form['sets']['header'] = [

+ 1 - 1
app/templates/layouts/form.forkbb.php

@@ -105,7 +105,7 @@
                 @elseif ('yield' === $cur['type'])
                 {!! $this->block($cur['value']) !!}
                 @elseif ('file' === $cur['type'])
-                <input @if ($cur['required']) required @endif @if ($cur['disabled']) disabled @endif @if ($cur['autofocus']) autofocus @endif class="f-ctrl" id="id-{{ $key }}" name="{{ $key }}" type="file">
+                <input @if ($cur['required']) required @endif @if ($cur['disabled']) disabled @endif @if ($cur['autofocus']) autofocus @endif class="f-ctrl" id="id-{{ $key }}" name="{{ $key }}" type="file" @if ($cur['accept']) accept="{{ $cur['accept'] }}" @endif>
                 @endif
                 @if ($cur['info'])
                 <p class="f-child4">{!! $cur['info'] !!}</p>