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
[LiveComponent] Files validation #1739
Comments
There may be something you're doing different from the demo (https://ux.symfony.com/demos/live-component/upload) i think ... do you have LiveProp for this file ? |
Yes I have LiveProps for my file like in the demo : #[LiveProp]
public ?string $fichierAudioName = null;
#[LiveProp]
public ?string $fichierAudioUploadError = null; The only thing different I can see is that I'm in a symfony form |
File input cannot be handled with other data i think |
So there is no solution to add constraints to files with DynamicForm on symfony Form ? |
No, i'm saying you cannot have both Live action handling and standard form handling at the same time i think. Not 100% sure to see who is who in your code, could you create a small reproducer ? |
I reproduced the bug on this repo : |
Any solutions ? |
I'm not sure because you have an error $file = $request->files->get('rdv')['fichierAudio']; After that, i think you should reset the form error but you never do cause you return before if (0 === \count($errors)) {
return;
}
// ... Finally, while looking at the debugger, it seems you send two actions at once (upload and save) .. so i'd start there and look step by step what's going on :) |
The error Warning: Trying to access array offset on null occurs when you don't choose file before clicking on the upload file button. I don't understand why I need to reset the form error before this return because if I enter in the if condition, I have no errors on the file validation (it's done like that in the demo but it works) Plus, when there is an error and I want to upload another file, It doesn't go to the validateFile method (only when I click on the uploadFile button) because the file disappears before |
As i said, I think there are two actions at once. Could you check in your profiler / web debugger ? |
Could you look what the "_batch" is sending ? |
Hello,
I have a problem to validate files with a DynamicForm.
There is my field :
Twig :
If I try to add file with this method, The form doesn't catch the error and the form is submitted. But if I do the constraint in the uploadFile method in my Form like this :
I have the validation error as I want but I can't replace the wrong file with another (It disappears from the form) and if the file is correct, the form is submitted si I don't want.
The text was updated successfully, but these errors were encountered: