Answer the question
In order to leave comments, you need to log in
How to show phone from database in yii2 using pjax?
$model->phone - phone in the database
There is a link on the page
<a href="#" class="phone-number">Показать телефон</a>
. Answer the question
In order to leave comments, you need to log in
Here is an example for you, but you do not understand what you are saying.
It can be something like this:
// PhoneView
Pjax::begin(['enablePushState' => false, 'timeout' => 2000]);
if (isset($phone)){
echo Html::tag('b', 'Вот ваш телефон: '.$phone);
}
else {
echo Html::a('Показать телефон', ['/phone/show', 'id' => $model->id]);
}
Pjax::end();
// PhoneController
public function actionView($id){
if (null !== $model = Phones::find(['id' => $id])){
return $this->render('PhoneView', ['model' => $model]);
}
throw new NotFoundException();
}
public function actionShow($id){
if (null !== $model = Phones::find(['id' => $id])){
return $this->render('PhoneView', ['model' => $model, 'phone' => $model->phone]);
}
throw new InvalidParamException();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question