Homepage

[DEPRECATED] Custom Attachments

Last edit: Jul 14, 2023

Warning

This article is deprecated. Please visit the updated guide - User Uploads

Custom Attachments are used to add one or more attachments to a Profile, or Record.

Defining

You can enable CustomAttachments by adding a Property with type set to file, for example:

- name: Agreement
  type: file

Form configuration

The Custom Attachment attribute must be defined in a form in order to allow and validate the form request.

...
fields:
  custom_attachments:
    agreement:
      file:
        validation:
          file_content_type: { allow: ['image/jpeg', 'image/png', 'application/pdf'] }
...

Fields

Each attachment supports the following self-descriptive fields:

Field name Type Note
file String File object associated with the custom attachment

Displaying, updating

After setting up attachments as described above, you can further customize them in the markup for the forms:


<label>
  <span>Select file...</span>
  <input accept=".pdf,.jpg,.jpeg,.png" name="{{ form.fields.custom_attachments.agreement.file.name }}" type="file">
</label>

<button>Submit file</button>

{% if form.errors['custom_attachments.agreement.file'] %}
  <p>{{ form.errors['custom_attachments.agreement.file'] }}</p>
{% endif %}

The example above shows the predefined attachment tag.

Using GraphQL to query for CustomAttachment

query test_attachment_query {
  records {
    results {
      certificate: custom_attachment(name: "agreement") {
        id
        file_name
      }
    }
  }
}

Questions?

We are always happy to help with any questions you may have.

contact us