The following may be the form data to submit
php
Array ([products] = = Array ([0] = = Array ([product_id] => ; [Product_sku] = 5614546542 [Quantity] = 1 [Price] => ; 34.00) [1] = = Array ([product_id] = 12 [Product_sku] = 5614546542 [Quantity] = 2 [price] and 34.00 ) [2] = = Array ([product_id] = [product_s KU] = 5614546542 [Quantity] = 1 [price] + 34.00) ) [Marketing] = = Array ([0] = = Array ([coupon] = 34SDHS 56aj45dh56 [Provider] = 1) [1] = = Array ( [Coupon] => 33454545324236 [provider] + 2)] [shop_id] = [Member_card] =&G T 3423432423123 [Submittime] = 2015-2-3 9:52:09)
I'm going to write a OrderForm model validation data;
Products correspond to a model, there is also a form validation
Marketing corresponds to a model, which also has form validation
OrderForm's rules should be how to write to achieve products variables corresponding to the rules within the products model;
The marketing variable corresponds to the rules within the marketing model;
Reply content:
The following may be the form data to submit
php
Array ([products] = = Array ([0] = = Array ([product_id] => ; [Product_sku] = 5614546542 [Quantity] = 1 [Price] => ; 34.00) [1] = = Array ([product_id] = 12 [Product_sku] = 5614546542 [Quantity] = 2 [price] and 34.00 ) [2] = = Array ([product_id] = [product_s KU] = 5614546542 [Quantity] = 1 [price] + 34.00) ) [Marketing] = = Array ([0] = = Array ([coupon] = 34SDHS 56aj45dh56 [Provider] = 1) [1] = = Array ( [Coupon] => 33454545324236 [provider] + 2)] [shop_id] = [Member_card] =&G T 3423432423123 [Submittime] = 2015-2-3 9:52:09)
I'm going to write a OrderForm model validation data;
Products correspond to a model, there is also a form validation
Marketing corresponds to a model, which also has form validation
OrderForm's rules should be how to write to achieve products variables corresponding to the rules within the products model;
The marketing variable corresponds to the rules within the marketing model;
Start by creating the model you want, adding ' properties that will save the values submitted by the form and corresponding validation rules/scenarios.
Loads the model into the view, specifying the model for the property when each form item is created, such as:$form->field($marketModel, 'market')->textinput();
Submit the form, and then refer to the steps below to load, verify, save.
Refer to the official documentation for the steps given
1. Instantiate model classes
2. Populate the models attributes with input data
3. Validate All Models
4. If validation passes for all models, save them
5. If validation fails or no data has been submitted, display the form
By passing all model instances to the view