Answer the question
In order to leave comments, you need to log in
How in yii2 is data written from post to the model?
I don't understand how this design works.
if (Model::loadMultiple($infoModels, Yii::$app->request->post())) { ... }
или
if ($model->load(Yii::$app->request->post())) { ... }
<?= $form->field($model, 'name')->textInput() ?>
Answer the question
In order to leave comments, you need to log in
First, see what goes from the form to the server through the debug panel in the browser.
Secondly, look at the examples of working with load and loadMultiple in the documentation, or in other extensions (look on github).
In general, there is not much difference how to display input - through yii, or "naked" html. The main thing is that the name field is filled in correctly. Accordingly, for loadMultiple, an array must be specified in your name. For example, you fill out a form with an application, there may be several services in the application. Example name="Bid[servicesIds][]"
. As a result, on the server you $_POST['Bid']['servicesIds']
will have an array of service ids.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question