Attributes store data in an application. Unlike components, attributes need to be defined first in the attributeTypes asset before they can be assigned to an object type. Once created, attributes can be referenced in templates to display them in the UI and store user data.
Attributes: Mind Map
This section is optional and serves to demonstrate, using an example, how to identify the attributes you need and understand their structure.
For consistency, we will:
- List the attributes required for our Recipe Manager application and assign them keys.
- Decide on the attribute type and determine the necessary features to define it.
- Features determine how an attribute appears in the UI and define its behavior. For a complete list, see Attribute Type Features.
- Why use features? Features allow you to define an attribute’s visual presentation once, so you don’t have to specify it each time the attribute is used.
| Object Type | Attribute Key | Attributes | Attribute Features |
|---|---|---|---|
| Space App Overview | app_description | Description (text) | is_html (allows rich-text formatting) |
| Cuisine | core#description | Description (text) | ` |
| Recipe | recipe_steps | Description (text) | is_html |
| Right-side panel | |||
recipe_last_made | Last Made | is_datetime (creates a date picker) | |
| Ingredient Category | core#description | Description (text) | ` |
| Ingredient | core#description | Description (text) | ` |
| Right-side panel | |||
ingredient_stock | Out of Stock | is_checkbox (creates a checkbox) | |
| In the screenshot below, you can see a text field and a date picker. |
For attributes using a key with core#, there’s no need to specify the attribute feature separately, as it is already defined in Dawiso’s core packages. In our example, since we only require the Description field for these cases, creating a new attribute type isn’t necessary.
Defining Attributes
Start with a blank attributeTypes template. Each JSON object in the array represents one attribute.
"attributeTypes": [
{
"key": "",
"name": "",
"features": [
{
"key": ""
}
]
}
]
| Property | Purpose |
|---|---|
key | The unique key of the attribute, used to assign the attribute to object types and templates. |
name | The name of the attribute, displayed in the UI above the corresponding input field. |
features | Specifies the type and behavior of an attribute, such as a text box, checkbox, or date picker. For more information, refer to the full list of available features. In most cases, you must explicitly set a value (true/false). If a feature is not specified, it defaults to false. |
Example: Recipe Manager Attributes
Click here to show the example.
In our Recipe Manager App, we use three different types of attributes to store and display data. Below is a summary of how they are used and defined in the package.
In the example snippet, you can see how attribute features determine the attribute type:
"attributeTypes": [
{
"key": "app_description",
"name": "App Overview Description",
"features": [
{
"key": "is_html" // Allows rich text formatting, ideal for long descriptions.
}
},
{
"key": "recipe_steps",
"name": "Recipe steps",
"features": [
{
"key": "is_html"
}
},
{
"key": "recipe_last_made",
"name": "Last made",
"features": [
{
"key": "is_datetime" // Creates a date-time picker to capture the last time a recipe was made.
}
},
{
"key": "ingredient_stock",
"name": "Needs restocking",
"description": "Information on whether restocking is needed.",
"features": [
{
"key": "is_checkbox" // Creates a checkbox for binary input.
}
]
}
],