-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Testing] CollectionType file upload #10809
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
Conversation
|
||
namespace App\Form; | ||
|
||
use App\Entity\Entity; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entity\Entity
- I think it's bag example. You can use User
or Task
or another entity used in other documentation articles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about App\Entity\Album
with a pictures
property?
if no data are passed by default, sometimes, you need to upload multiple files (using this CollectionType), | ||
keeping in mind this logic, it can be hard to handle the upload. | ||
|
||
Let's imagine a simple form which define a collection of FileType:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defines
} | ||
} | ||
|
||
Testing this type can be hard as explained earlier, trying to use UploadedFile isn't possible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be hard ... isn't possible
- to many restrictions, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Guikingone thanks for this contribution. Before reviewing it I wonder if we could solve the underlying problem instead of documenting it. Specifically, can we solve this in some way?
By default, a CollectionType isn't available in the form
during functional tests if no data are passed by default.
Ping @HeahDude. Thanks!
@javiereguiluz I think it can be solved (maybe via a |
@javiereguiluz After discussing this PR with @HeahDude, it's not a bug, it's more a special case I was blocked by, if it's not a problem for you, I can keep this PR in order to improve the documentation for the usage of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Guikingone for opening that PR. But wouldn't it be some kind of duplicate of #10527.
|
||
namespace App\Form; | ||
|
||
use App\Entity\Entity; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about App\Entity\Album
with a pictures
property?
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | ||
use Symfony\Component\Form\Extension\Core\Type\FileType; | ||
|
||
class DefaultUploadType extends AbstractType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would make it a GalleryType
|
||
public function getBlockPrefix() | ||
{ | ||
return 'some_type'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this app_gallery
I'll take a look at the linked PR and see if it worth the work to improve this one 🙂 |
Hi @Guikingone! #10527 (the other PR) was just closed, based on @xabbuh's comment: "IMO when your functional test requires JavaScript to be executed you should use a real browser in the background (for example using Panther) instead." It seems like the solution proposed in this PR is just as fragile as the solution in the other PR (i.e. it relies on implementation details of the Form component that are not under the control of the application). Do you agree with this conclusion? And if you don't, do you have time to further work on this PR? |
Hi @wouterj 👋 Yes, I agree with this conclusion, with time, I agree that every time that you need to test a JS-dependant interface, you should use tools like Panther, Cypress, etc, the default Bridge is great but not enough for advanced use cases. As discussed with @javiereguiluz, I also think that the documentation need to add pages about using Panther (maybe in the So 👍 for me on your proposal. |
Alright, I've reopened #12200 (an issue of yours 😄 ) and will close this one then. Thanks for your reply! |
Hi everyone,
Recently, I've been blocked by a CollectionType which define a child form (using VichUploaderBundle but the logic stay the same for default FileType), I wasn't able to test it during functional tests, I've found a way to do it and I think it can a good idea to improve the doc in order to explain how to do it.
Thanks for the feedback 😊
PS: Some work must be done in the sentences