Pre-fill support for file input (#222)

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
formsdev
2023-10-20 14:30:35 +05:30
committed by GitHub
parent c470791282
commit 4614dc0f18
6 changed files with 63 additions and 17 deletions

View File

@@ -16,15 +16,20 @@ class UploadAssetRequest extends FormRequest
*/
public function rules()
{
$fileTypes = [
'png',
'jpeg',
'jpg',
'bmp',
'gif',
'svg'
];
if ($this->offsetExists('type') && $this->get('type') === 'files') {
$fileTypes = [];
}
return [
'url' => ['required',new StorageFile(self::FORM_ASSET_MAX_SIZE, [
'png',
'jpeg',
'jpg',
'bmp',
'gif',
'svg'
])],
'url' => ['required', new StorageFile(self::FORM_ASSET_MAX_SIZE, $fileTypes)],
];
}
}