Answer the question
In order to leave comments, you need to log in
How to make a multidimensional array from different table data in yii2 and display it in one variable?
I use this widget https://github.com/unclead/yii2-multiple-input to add links with a title for a post.
So, in his use case, he shows how to use, stuff all the title and link data (in my case) into json and save it in one base field
$model->sites = \yii\helpers\Json::encode($model->sites);
$model->save();
public function afterFind() {
parent::afterFind();
$this->sites = \yii\helpers\Json::decode($this->sites);
}
<?= $form->field($model, 'sites')->widget(MultipleInput::className(), [
'columns' => [
[
'name' => 'title',
'title' => 'Название лендинга',
'enableError' => true,
'options' => [
'class' => 'input-priority'
]
],
[
'name' => 'link',
'title' => 'Ссылка',
'enableError' => true,
'options' => [
'class' => 'input-priority'
]
]
]
]);
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question