Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If a user uploads a file, then submits and validation fails, the 'Private' checkbox disappears. The result is that the file definitely goes public.
I have looked a bit into it, looks like the module's theme function isn't used anymore after validation fails. A possible reason might be that the theme function is changed during form_alter, and form_alter does not get triggered on validation failure (although I used to think that the '#theme' would be saved in the form_cache...)
Best regards,
Khaled
Comment | File | Size | Author |
---|---|---|---|
#4 | private_upload-948630-1.patch | 9.86 KB | berliner |
#2 | private_upload-948630.patch | 9.85 KB | berliner |
Comments
Comment #1
berliner CreditAttribution: berliner commentedI confirm this error. Might be related to #671574: Document that hook_form_alter not called after a form fails validation
I tested further and tried to move some logic from hook_form_alter to a function called after the build, but it didn't work for me neither. Anyone any idea?
Comment #2
berliner CreditAttribution: berliner commentedAfter digging through the code of the private_upload module and the core upload module I think the problem is, that upload_js() overwrites the cached form and thus the changes made by private_upload's implementation of hook_form_alter().
I tried to cope with this issue in re-implementing the form cache strategy of the upload module into private_upload. See the attached patch that solves the issue for me. It includes a change to the hook_nodeapi() implementation in order to give all files that are attached to a node a private attribute, reflecting the private state of each file. Also I removed private_upload_form_validate() and private_upload_form_submit() because the former is never used and I couldn't see why it should be. The latter is not necessary anymore with the new changes, because the private checkbox now integrates correctly into the form and its value is accessible in nodeapi's insert/update operation.
I would have liked to keep this patch smaller, but the changes were rather substantial.
Comment #4
berliner CreditAttribution: berliner commentedThe last patch didn't work when previewing a node. Should be fixed now.