At the moment, these checks are made in the view. Check how to move this to the form. Maybe 2 more properties can be defined in the form: item_cls and category_cls. These will be passed from the view. Then, define a custom validation for name which checks that name does not exist and another one for the category which verifies that category exists.
At the moment, these checks are made in the view. Check how to move this to the form. Maybe 2 more properties can be defined in the form: item_cls and category_cls. These will be passed from the view. Then, define a custom validation for name which checks that name does not exist and another one for the category which verifies that category exists.