Skip to content

Commit

Permalink
增加设置 input accept 属性
Browse files Browse the repository at this point in the history
  • Loading branch information
deatil committed Dec 25, 2023
1 parent 3feabbb commit 2981651
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ $form->video('video','视频')
```
path(string) : 快速定位目录,默认为根目录
nametype(string) : 文件重命名方式 uniqid|datetime|sequence|original,默认 uniqid
accept(string) : 设置 input accept 属性, 自定义,默认类型不设置
pageSize(int) : 弹出层列表每页显示数量
limit(int) : 限制条数
remove(boolean) : 是否有删除按钮
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ $(function () {
'potx', 'ppsx', 'ppam', 'potm', 'ppsm'
];

// 匹配 ppt
// 匹配 xls
var xls = [
'xls', 'xlt', 'xla', 'xlsx', 'xltx', 'xlsm',
'xltm', 'xlam', 'xlsb'
Expand Down
2 changes: 1 addition & 1 deletion resources/views/field.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class="close lake-form-media-close"
<div class="mailbox-controls with-border lake-form-media-actions-label" style="margin-left: 10px;">
<label class="btn btn-primary lake-form-media-upload-label">
<i class="fa fa-upload"></i>&nbsp;&nbsp;{{ LakeFormMedia::trans('form-media.upload') }}
<input type="file" class="hidden file-upload lake-form-media-upload" multiple="" />
<input type="file" class="hidden file-upload lake-form-media-upload" multiple="" accept="{{ $options['accept'] }}" />
</label>

<label class="btn btn-light lake-form-media-modal-order"
Expand Down
36 changes: 26 additions & 10 deletions src/Form/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Field extends BaseField
protected $limit = 1;
protected $remove = false;

protected $accept = '';
protected $nametype = 'uniqid';
protected $pageSize = 120;

Expand Down Expand Up @@ -264,6 +265,19 @@ public function remove(bool $value = true)
return $this;
}

/**
* 设置 input accept 属性
* 常用类型 * /* audio/* video/* image/*
*
* @return $this
*/
public function accept(string $accept)
{
$this->accept = $accept;

return $this;
}

/**
* 设置上传保存文件名类型
*
Expand Down Expand Up @@ -352,6 +366,7 @@ public function render()
$limit = $this->limit;
$type = $this->type;
$disk = $this->disk;
$accept = $this->accept;
$nametype = $this->nametype;
$pageSize = $this->pageSize;
$remove = ($this->remove == true) ? 1 : 0;
Expand Down Expand Up @@ -400,26 +415,27 @@ public function render()

$this->addVariables([
'options' => [
'path' => $path,
'limit' => $limit,
'path' => $path,
'limit' => $limit,
'remove' => $remove,
'type' => $type,
'disk' => $disk,
'type' => $type,
'disk' => $disk,

'accept' => $accept,
'nametype' => $nametype,
'pagesize' => $pageSize,

'showtitle' => $showTitle,
'showtitle' => $showTitle,
'multiplechoice' => $multipleChoice,
'showicon' => $showIcon,
'showicon' => $showIcon,

'resize' => implode(',', $resize),
'resize' => implode(',', $resize),

'saveFullUrl' => $saveFullUrl,

'rootpath' => $rootpath,
'get_files_url' => $this->listUrl,
'upload_url' => $this->uploadUrl,
'rootpath' => $rootpath,
'get_files_url' => $this->listUrl,
'upload_url' => $this->uploadUrl,
'create_folder_url' => $this->createFolderUrl,
],
]);
Expand Down
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?php

return [
'1.0.32' => [
'修复弹出选择框标题显示问题。',
],
'1.0.33' => [
'修复上传文件原始命名保存名称错误问题。',
],
Expand All @@ -16,4 +13,7 @@
'1.0.37' => [
'修复预览图标不准确问题。',
],
'1.0.38' => [
'增加设置 input accept 属性。',
],
];

0 comments on commit 2981651

Please sign in to comment.