I have a model class as ItemDetails in which I have declared a public variable $dummy and its rule is set to required
public $dummy;
public static function tableName()
{
return 'item_details';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['item_price', 'item_available_qnt','dummy'], 'required'],];
}
And in view when I submit my form, elements ‘item_price’, ‘item_available_qnt’ are getting validated and an error is displayed for them but ‘dummy’ is not getting validated.
$modelItem = new ItemDetails();
<?php $form = ActiveForm::begin(['method'=>'post','action'=>'index.php?r=item/default/showitemdetailsforinsert']) ?>
<?= $form->field($modelItem, 'item_price')->textInput(['style'=>'width:100px']); ?>
<?= $form->field($modelItem, 'item_available_qnt')->textInput(['style'=>'width:100px']); ?>
<?= $form->field($modelItem, 'dummy')->textInput(['style'=>'width:100px']); ?>
Not sure why ‘Dummy’ is not getting validated and no error is displayed when it is blank. Please help!