Create New Forms#

Portfolio Backend allows to create custom form extensions.

Warning

Adapting Portfolio can lead to incompatibilities with other Portfolios and Showroom.

Necessary steps:

  • Create a schema in src/portfolio/core/schemas/entries

  • Add schema to ACTIVE_SCHEMAS in django .env

Specifications for Frontend#

In order for the frontend to display the newly designed form properly, it is necessary to adapt the x-attributes of each field accordingly, otherwise the display will always be a plain text field.

Setting x-attributes for the Frontend#

Available attributes:

attribute

relevant for

default*

allowed values

description

hidden

all

False

True, False

indicate if this data attribute should be considered for form creation (e.g. true for id)

field_format

all

full

full, half

specify if the field should fill full width or half in a form
(in case it is a ‘half’ field make sure it has a second ‘half’ field as well, otherwise the space will be empty)

field_type

all

text

text, autocomplete, chips, chips-below, date, multiline, group

which kind of field should be shown front-end:
text: simple text field
autocomplete: text field with autocomplete functionality (source needed!)
chips: input field with options (optional: dynamic autocomplete) that creates chips out of selected options
(if single or multi chips will be determined automatically from field type being an array or object)
chips-below: same as chips, however chips are not added inline but below the input field
date: a date field (different formats)
multiline: a multiline text field
group: indicates that the fields specified within should be grouped

form_group

all

-

1, 2

specify this value if you want your form separated upon type selection - all fields with ‘1’ will stay on top, all fields with value ‘2’ with move below the type specific fields

placeholder

all

-

string or object

Add a placeholder displayed in the input field
A string for all fields except date fields - there it should be an object with ‘date’ and (if necessary) ‘time’ attributes that contain the relevant string
default placeholder (‘Enter xxx’) can be added with utils function placeholder_lazy(label)

order

all

this should be specified for all fields otherwise sorting will be random

number

this will specify the order in which the fields are displayed in the form

source

chips, chips-below, autocomplete

-

a API endpoint

if the field has a autocomplete functionality (autocomplete field or dynamic chips inputs (dynamic_autosuggest = true) or options (dynamic_autosuggest = false) this route is required to fetch these options
(the base url for the API is specified in the front end configuration)

source_*

chips, chips-below

-

a API endpoint

as above, to specify additional sources (URLs) for prefetching
(e.g. used for text types –> source_type or roles –> source_roles)

prefetch

chips, chips-below

[]

e.g. ‘source’

specify the attributes that contain an URL where options should be prefetched (=for chips inputs that are not dynamic!)
(for the example above e.g. ‘source’, ‘source_types’, ‘source_roles’)

set_label_language

chips

False

True, False

specify if the field data have language specific content (e.g. { ‘en’: ‘xxx’, ‘de’: ‘yyy’ })
(e.g. true for languages or materials fields)

date_format

date

day

day, month, year, date_year

the format of the date field, if day, month or year it will only be possible to enter those, if date_year switch buttons will be displayed to allow switching between day and year format

dynamic_autosuggest

chips

False

True, False

define if chips should have a dynamic autocomplete –> this means matching results are live fetched from the API on user input

allow_unknown_entries

chips

False

True, False

define if only options available in the chips input drop down can be used or user can just enter any string

sortable

chips, chips-below

False

True, False

should chips be sortable

default_role

chips

-

a contributors uri (as defined in VocBench/Skosmos)
e.g. http://base.uni-ak.ac.at/portfolio/vocabulary/software_developer

this is relevant for all contributors related fields, in order to save the relevant role, a uri needs to be specified here
can be done with function get_uri(role)

equivalent

chips

-

a field name, e.g. ‘contributors’

attribute to indicate that this field is connected to more general field (atm only used for contributors)

show_label

groups

False

True, False

indicates if field groups should have a label