Basically, I am building an online shop where the user can create products with options (so, let's say, a size and a color). When all the options are set, they must provide a quantity and the SKU of each product.
I was thinking of making a two step form.
1st step: they select the name, description, images and create the options (size[sm, m, l, xl] and color[blue, red, yellow]). On the page after, I generated a list of forms for each option (small yellow jacket, small blue jacket, small white jacket, medium yellow jacket, medium blue jacket, medium white jacket, etc.)
Basically, a lot of lines of form that I have to validate. However, I don't see how I can get the data and validate it.
The generated names will each have an associated id and that id needs to be in the form. I was thinking of putting it in the names (sku-1, quantity-1, but this wouldn't work for validation). Thought about making an array but how would I know which value belongs to which product?
How do you handle form validation/matching when you have a lot of models to work with like in my case?
question from:
https://stackoverflow.com/questions/65867000/how-to-validate-a-form-with-multiple-models 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…