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 |
field_type |
all |
text |
text, autocomplete, chips, chips-below, date, multiline, group |
which kind of field should be shown front-end: |
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 |
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 ( |
source_* |
chips, chips-below |
- |
a API endpoint |
as above, to specify additional sources (URLs) for prefetching |
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!) |
set_label_language |
chips |
False |
True, False |
specify if the field data have language specific content (e.g. { ‘en’: ‘xxx’, ‘de’: ‘yyy’ }) |
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) |
this is relevant for all contributors related fields, in order to save the relevant role, a uri needs to be specified here |
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 |