Reputation: 89
I have two models :
Subnet(id,name,...) and Ip(ip , objectid , ...)
in SubnetController I have :
public function actionView($id)
{
$ips = Ip::find()->where(['subnetID' => $id])->all();
if (!$ips) {
echo "<script type='text/javascript'>alert('No IP used yet');</script>";
}
return $this->render('view', [
'model' => $this->findModel($id),
'ips' => $ips,
]);
}
I want to have all IPs in editable-view :
<?= Editable::widget([
'model' => $ips,
'attribute' => 'ip',
'type' => 'primary',
'size'=> 'lg',
'inputType' => Editable::INPUT_TEXT,
'editableValueOptions' => ['class' => 'text-success h3']
]); ?>
But I get error:
Either 'name', or 'model' and 'attribute' properties must be specified.
I read all documentations!!! What should I do to list all of my IPs in Subnet view file?
Upvotes: 0
Views: 803
Reputation: 532
i think you should iterate through the $ips variable, since it it an array of Ip. So in your view
foreach($ips as $ip) {
echo Editable::widget([
'model' => $ip,
'attribute' => 'ip',
'type' => 'primary',
'size'=> 'lg',
'inputType' => Editable::INPUT_TEXT,
'editableValueOptions' => ['class' => 'text-success h3']
]);
}
Upvotes: 1
Reputation: 1579
It mean is that you must have defined the ip field in model. Have you defined it in model ?.
It should look like this :
<?= Editable::widget([
'model' => 'ip',
'attribute' => 'ip',
'type' => 'primary',
'size'=> 'lg',
'inputType' => Editable::INPUT_TEXT,
'editableValueOptions' => ['class' => 'text-success h3']
]); ?>
Upvotes: 0