-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FileUpload dimensions() validation #11904
Comments
If I put like this (without dynamic) then it's working Forms\Components\FileUpload::make('img')
->label('img')
->image()
->required() // this is working
->rules([
// 'required',
'dimensions:width=100,height=200',
// Rule::dimensions()->width(10)->height(50),
]), But In dynamic it's not Forms\Components\FileUpload::make('trans.'.$language->id.'.image')
->label('image')
->image()
->required() // this is working
->hiddenLabel()
// below rules() is not working
->rules([
// 'required',
'dimensions:width=100,height=200',
// Rule::dimensions()->width(10)->height(50),
]), Screencast.from.03-18-2024.02.01.55.PM.webm |
When #11907 is released, you'll be able to use |
Hi Dan, I've updated to Forms\Components\FileUpload::make('img')
->label('img')
->image()
->nestedRecursiveRules([
'required',
'dimensions:width=100,height=200',
]), |
I've converted this to a feature request for a |
For ease of checking
// rules() is working if Fileupload is not dynamic components
Forms\Components\FileUpload::make('img')
->rules([
'dimensions:width=100,height=200',
]), Using Forms\Components\FileUpload::make('img')
->nestedRecursiveRules([
'dimensions:width=100,height=200',
]), And now |
It's also seems like I cannot change validation messages which is inside Forms\Components\FileUpload::make('img')
->required()
->rules([
'dimensions:width=100,height=200',
])
->validationMessages([
'required' => 'Error!!!!', // working
'dimensions' => 'Dimension error!', // not working
]) Cause this one is working fine Forms\Components\TextInput::make('name')
->rules([
'required', 'min:3',
])
->validationMessages([
'required' => 'Error!!!!',
'min' => 'Min error!!',
]), |
refer to this |
Just sharing this related discussion: #5037 Wouldn't it be better performance-wise to implement this on the frontend using FilePond's image validate size plugin? https://pqina.nl/filepond/docs/api/plugins/image-validate-size/ My main use case would be setting a min and max rather than exact dimensions. That'd prevent over- or under- sized images from ever hitting the server. Which would really reduce bandwidth and load. |
Sorry to dive in on this one, it's the only related issue I could find before opening a new one... not sure if this actually related though. I'm getting an issue when using a rule of I've had to remove the rule for now. |
Yeah this would be ideal. is this possible right now? |
Package
filament/filament
Package Version
v3.2.51
Laravel Version
v11.0.7
Livewire Version
v3.4.9
PHP Version
v8.3.4
Problem description
When rendering dynamic components based on different table/model, the
rules()
orrule()
is not working in FileUpload, but If I used "predefine methods (?)" like->required()
it's working tho.. This same behaviour is working fine for TextInput, but not in FileUploadExpected behavior
Expected that
rules() or rule()
working in dynamic components for FileUploadSteps to reproduce
Install, check
Post resource
and you can see therules()
is working inTextInput
but not inFileUpload
Reproduction repository
https://github.com/valpuia604/dynamic-component
Relevant log output
No response
Update:
I've check more and more and I think that
->rules([])
is not working inFileUpload
whether it's dynamic or notDonate 💰 to fund this issue
The text was updated successfully, but these errors were encountered: