A
A
Alexander2017-01-09 17:07:10
MySQL
Alexander, 2017-01-09 17:07:10

What needs to be written in the model to save the data through the form?

f26c0496dd764de58c0d1141c8c8357f.png
Tell me please, I just can’t understand what to write ... to fill in the data of related tables.
This model is connected in fact with all the tables that I have. How can I fill in all the tables at once through the form?
What should be written in it? Rules, of course, but here a voros also arises - Rules in each model separately for their rows in the database? Or is it possible to do everything in this one model?
And how to save the actual data, such as through This model-> connection -> save () will work?
That is, I want to fill all the tables from one form at a time, it’s clear that the primary secondary keys will have the same value and 2 form fields are not needed for one value (for example, I have an ISBN primary key for the books table and a secondary key for Series), is it possible to with one form value fill immediately isbn here and there ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2017-01-10
@koshalex

Rules in each model separately for their rows in the database? Or is it possible to do everything in this one model?

Each model describes a specific table, so each model class must have its own validation rules for its attributes
you can’t do this, you need to save the data of each model separately, and then link them, as indicated in the dock, the link to which was given by @uDenX
additional fields do not need to be done, you must link models on the server

D
Denis Derepko, 2017-01-09
@uDenX

Saving relations

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question