How to connect form with entity

This tutorial shows you how to connect form with entity. In our example we will make form for adding and editing products on promotion.

Example

1. Login into developer panel of application.

2. Click on Pages menu item.

3. Select page pageProductsOnPromotion.

4. Drag and drop Form component from all components list to pageProductsOnPromotion.

5. In dropped form component properties, for Entity based form property choose Yes and for Entity choose Products on promotion. Now every component you drop on form you can connect with single attribute of entity you chose.

Connect form with entity

6. Drag and drop Single select component from all components list to formAddNewProductOnPromotion.

7. In dropped form component properties, for Entity attribute property choose Promotion. 

Connect form with entity

8. Repeat steps 6 and 7 for others entity attributes.

9. Drag and drop Button component from all components list to formAddNewProductOnPromotion. Name dropped button component ButtonSaveNewPromotion.

10. Drag and drop Action component from all components list to ButtonSaveNewPromotion.

11. In dropped form component properties, for Action type property choose Entity and in Action code type SAVE. This action code will save data to entity.

Connect form with entity

12. Now we will make action to load data in case we want to edit data about entity. Drag and drop Hidden component from all components list to formAddNewProductOnPromotion. In dropped form component properties, for Entity attribute property choose Id. 

13. Drag and drop Action component from all components list to FormAddNewProductOnPromotion.

14. In dropped form component properties, for Action type property choose Entity and in Action code type LOAD[Id = {HiddenPromotionId}]. This action code will load data about entity by Id which value will be transfered from DatatableProductsOnPromotion to component HiddenPromotionId by clicking on button Edit promotion.

Edit action

15. Click on Save changes, go into your application and check out the results.