Issue
i have used ArrayDataProvider in controller yii2.
<?php
public function actionPagination_product2(){
$tb_tab=Tablet::tableName();
Digital.inner_memory')->asArray()->all();
$data = Digital::find()->joinWith('tablet',true,'Left Join')->where('Tablet.sup_id = Digital.id')->asArray()->all();
$dataProvider = new ArrayDataProvider([
'allModels' => $data,
'sort' => [
'attributes' => ['id'],
],
'pagination' => [
'pageSize' => 20,
],
]);
return $this->render('pagination_pro2', [
'dataProvider' => $dataProvider,
]);
?>
and in view pagination_pro2 i have
<?php
use yii\widgets\ListView;
echo ListView::widget([
'dataProvider' => $dataProvider,
'itemView' => '_page1',
]);
?>
and in view _page1 i have
<?php
use yii\helpers\Html;
use yii\helpers\HtmlPurifier;
?>
<div class = "user">
<?php
foreach($model as $attribute => $value) {
// do your stuff here
if(isset($model['sim_num'])){
echo "aaaa";
}
}
?>
</div>
that works true.but i want to access one by one of model attributes.
are that works true? what have to do? tnx
Solution
To access model attributes one by one in view _page1
use foreach
loop:
If your data is just array:
foreach($model as $attribute => $value) { // do your stuff here }
If your array is array of models:
foreach($model->attributes as $attribute => $value) { // do your stuff here }
Answered By - Yupik
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.