Answer the question
In order to leave comments, you need to log in
How to save the value of a text field after submitting to a form in yii2 framework?
How to save the value of a text field after submitting to a form in yii2 framework?
In the field, enter the value -
After sending to the form, as usual, there is a void in the field
How to do that after submitting the form, there is data left.
Code
file main.php
$form = ActiveForm::begin();
$form->field($model, 'price')->textInput(['value' => $model->price,'maxlength' => true])
ActiveForm::end();
public function actionIndex()
{
$model = new Product();
if($model->price){
$price = $model->price;
$query = Product::find()->where(['price' => $price]);
}
return $this->render('index', compact('hits','pages','model'),[
'dataProvider' => $dataProvider,]);
Answer the question
In order to leave comments, you need to log in
You need to upload the entered data in the form:$model->load(Yii::$app->request->post)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question