![]() FileTestForm uses the file_save_upload function to save file server-side. I tried to look at the FileTestForm class which uses the file field. The next logical destination was to look at the file form field from the FAPI. And you would get a File class instance in your submitForm handler when you call $form_state->getValue('file_field_name') in the handler (well actually an array of File instances). ManagedFile form field would automatically upload the file to Drupal in an Ajax’ed form submission as soon as a file is selected. Which completely disassociates the responsibility of handling file uploads from your Drupal forms. Plus I thought the functionality might come-in handy in future also when for example, providing drop-areas for files (for drag-drop file upload) which doesn’t use the traditional form fields.Īlmost all file-upload functionality we create today for our Drupal-based products uses the managed_file form fields. But we had a legacy form, a lot of which was generated client-side in javascript and submitted as json to the server.Īnd my focus was on getting the job done quickly (of adding the new file field support) to the form rather than re-writing the entire client-side functionality to use Drupal’s Ajax’ed forms. ![]() And I would agree to the suggestion for most use-cases. I know almost all of Drupal’ers would point towards using Drupal’s ajax-based Form API (FAPI) to inject the new file fields on the form. While working with Mart, we had a situation recently where we needed to add file ( ) form fields dynamically in javascript client-side. I hope all of you and your loved ones are keeping safe. What, almost after 6 months I guess!! We came out from one lockdown, fumbled the freedom around to go into another and now coming out of the second all during this time. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |