Hello,
please, a little help.
In DetailView it’s simple getting data of a related table:
<?= $form->field($model, 'userid')->textInput(['maxlength' => 255, 'value' => 'user.username', 'readonly' => true]) ?>
But I can’t figure out how to obtain the same in Activeform:
<?= $form->field($model, 'userid')->textInput(['maxlength' => 255, 'value' => 'this don't work: user.username', 'readonly' => true]) ?>
This in model:
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'userid']);
}
Edit. Ok, I got it.
in controller:
$model = $this->findModel($id);
$usr = $model->user;
...
return $this->render('update', [
'model' => $model,
'usr' => $usr,
in the view:
<?= $this->render('_forupdate', [
'model' => $model,
'utente' => $utente
]) ?>
...
<?= $form->field($usr, 'username')->textInput(['maxlength' => 255, 'readonly' => true]) ?>