Answer the question
In order to leave comments, you need to log in
Why doesn't yii2 see the variable?
Names changed for example
Model code:
/models/myModel.php
namespace app\models;
use yii\base\Model;
class pressureForm extends Model
{
public $date;
public $pressure;
public $condition;
public function rules()
{
return [
[['date', 'pressure', 'condition'], 'required']
];
}
}
public function actionPage()
{
$pressureForm = new form();
return $this->render('page',[
'pressureForm' => $pressureForm,
]);
}
/* @var $this yii\web\View */
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
?>
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($pressureForm, 'date')->widget(yii\jui\DatePicker::className(), ['dateFormat' => 'yyyy-MM-dd']) ?>
<?= $form->field($pressureForm, 'pressure')->textInput(array('value'=>$pressure)); ?>
<?= $form->field($pressureForm, 'condition')->radioList(['1' => "Да", '0' => 'Нет']); ?>
<div class="form-group">
<?= Html::submitButton('', ['class' => 'btn btn-success glyphicon glyphicon-plus']) ?>
</div>
<?php ActiveForm::end(); ?>
foreach ($this->_behaviors as $behavior) {
if ($behavior->canGetProperty($name)) {
return $behavior->$name;
}
}
}
if (method_exists($this, 'set' . $name)) {
throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
} else {
throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question