just not sure how to add the Rates to this equation.
before the return I’m already iterating through the modelsElements for another reason and thought this would be the place to do so, but am drawing a complete blank.
foreach ($modelsElements as $modelElement ) {
$modelElementRates = $modelElements ->Rates; // drawing a blank
}
maybe this is completely wrong.
So I be doing this in the view since I already have the $modelsElements? But of course I need this to get saved with the main model.
Anyone able to kick me in the right direction or provide a link, example to learn from.
$model = $this->findModel($id);
$modelsElements = $model->projectsElements;
$modelsElementsRates = ????
if ($model->load(Yii::$app->request->post())) {
// Look at this after
}else{
// foreach ($modelsElements as $modelElement ) {
// $modelElementRates = $modelElement->Rates; //This does work, but only for the current modelElement
// }
return $this->renderAjax('update', [
'model' => $model,
'modelsElements' => (empty($modelsElements)) ? [new ProjectsElements] : $modelsElements,
'modelsElementsRates' => ???,
]);
}
I also figure that I could simply define the model in the view, and I can indeed retrieve the data that way to render it, but upon submission it doesn’t appear to come through with the POST.