Hi,

When node form validation fails (e.g. missing title), the attachment tab of newly uploaded file is displayed without the private checkbox. Hence when user validates again the form, the private checkbox is lost making the file public.

Thanks

Laurent

Comments

skcuslapurd’s picture

Had the same issue. It appears to be because the upload module (function upload_js) caches the node form before the private upload modules form_alter has a chance to put in the private checkbox, so after validation the form is loaded from the cache and displayed without the private upload bits.

The following may be of use to someone. Put it in private_upload_form_alter at the end of the elseif ($form_id == 'upload_js') { block.

CAVEAT : This isn't tested to any extent other than it appears to work for me and so might work for others.

                                                                                                                           
      if (isset($_POST['form_build_id'])) {
        $cached_form_state = array();
        $cached_form = form_get_cache($_POST['form_build_id'], $cached_form_state);
        if (isset($cached_form['attachments']['wrapper']['files'])) {
          $cached_form['attachments']['wrapper']['files'] = $form['files'];
          form_set_cache($_POST['form_build_id'], $cached_form, $cached_form_state);
        }
      }