Wix Blocks: Creating and Managing Custom Type Properties in the Widget API
3 min read
Wix Blocks is currently open to a limited number of users.
In your Widget API, you can create custom property types that fit the requirements of your app.
For example, if you have a shopping widget, you may want to create a type that represents a customer, or a product, such as a shoe.
The Customer type could include the following properties: name (text), address (text), age (number) and customerId (number).
The Shoe type could include the following properties: model (text or number, depending on your catalog), size (number), color (text) and productId(number).
Tip
Notice that a custom type property (such as Customer or Shoe) also has properties, which are the fields of this new datatype that you created. However, these inner properties can only have simple types: text, number, boolean, image and URL. They cannot break down into more custom type properties.
Create a Property with a Custom Type
- Click the Widget API icon.
- Click Add New Property or hover over Properties and click the icon.
- Give your property a significant name and a display name.
- Expand the Property Type menu.
- Click Create New Custom Type.
- Name the custom type.
- Click Add Property to add properties (fields) to the type.
- Repeat the process until you've added all the properties of the type.
- Click Save.
8. Add a description to your new property.
9. Add default values to the type's fields if you want (such as a default age for the customer).
10. Click Create.
Tip
In the above example, the Customer type can be used for various properties in the Widget API, such as ExsitingCustomer, FirstTimeCustomer, PotentialCustomer.
Edit a Custom Property Type
Edit a custom type by hovering over the type and clicking the Edit icon. You can then edit or remove any of the properties in that type.
Important
- If you remove a property from your custom type, it is removed from the Widget API properties of the custom type. If you add a property to your custom type, it is automatically added to the existing Widget API properties of that custom type.
- If you change the name of the custom type it is automatically changed in each Widget API property that is of that type.
Delete a Custom Property Type
Delete a custom type by hovering over the type and clicking the Delete icon. You can only delete a custom type if no Widget API properties are of that type.
Did this help?
|