Hello experts,
Can you please guide me how to save data in the database? below is the model, controller and view code for your reference.
Model:
class TestForm extends Model
public static function tableName()
{
return '{{%test%}}';
}
{
public $value1;
public $value2;
public $value3;
public function rules()
{
return[
['value1','required'],
['value2','required'],
];
}
public function attributeLabels()
{
return [
'value1' => '',
'value2' => '',
'value3' => 'Test output',
];
}
Controller:
class TestController extends Controller
{
public function actionTest(){
$val1='A';
$val2='B';
$val3='C';
return $this->render('index', ['Text1' => $val1, 'Text2' => $val2, 'Text3'=>$val3]);
}
}
View:
<div id= "content">
<?php $form = ActiveForm::begin([
'id' => 'form-testform'])?>
<div class="row">
<div class="col-xs-1">
<?=$Text1 ?>
</div>
<div class="col-xs-1">
<?=$Text2 ?>
</div>
<div class="col-xs-1">
<?=$Text3 ?>
</div>
</div>
<div class="form-group"><?php ActiveForm::end(); ?> </div>
Thanks in advance.
Regards,
Sid