Complex forms with multiple models
When dealing with some complex data, it is possible that you may need to use multiple different models to collect the user input. For example, you have an order form with user information such as first name, last name, and phone number; you also have a delivery address and some kind of product.
You would like to save all this data in one form. With Yii models and support forms, you can easily do this. Assuming that the user info will be stored in the user table and in the order form, we will save product information and the user_id
of the user who has ordered a product. We also have a product table with some information in it.
Getting ready
- Create a new application by using the Composer package manger, as described ...
Get Yii2 Application Development Cookbook - Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.