CulturalMe/meteor-slingshot

How to make the upload conditional ?

Opened this issue · 0 comments

Hello,
I have a form with multiple fields: how can I validate the form even without a image ? Right now, it throws "not a file", and the form is not saved unless I add an image (even if I edit the form).

  handleSubmit(e, props) {
    e.preventDefault();
upload.send(document.getElementById("uploadFile").files[0], function(
      error,
      downloadUrl
    ) {
      uploader.set();


      if (error) {
        alert(error);
      } else {
      console.log("Success!");
      console.log("uploaded file available here: " + downloadUrl);

      Meteor.call(
        "laws.update",
        lawId,
        titleLoi,
        abstractLoi,
        downloadUrl
      );
      }
      uploader.set(upload);
    });