I try to call a setting form, which shows input forms for saving data into price database.
My model throws the above Exception during rendering:
Unknown Property – yiiaseUnknownPropertyException
Setting unknown property: yiivalidatorsNumberValidator::0
error in line of _price-item:
$form->field($model, "[{$i}]credits")->textInput(['maxlength' => 8])
Model:
<?php
namespace appmodels;
use Yii;
/**
* @package appmodels
*
* @property integer $id
* @property integer $credits
* @property integer $price
* @property integer $reduced_price
* @property integer $discount
* @property string $start
* @property string $end
* @property integer $active
*/
class Price extends appaseActiveRecord
{
public function rules()
{
return [
[['credits'], 'integer', 'required'],
[['price'], 'integer','integerOnly' => false,'required', 'min' => 0, 'max' => 10000],
[['reduced_price','discount'],'integer','integerOnly' => false,'min' => 0, 'max' => 10000],
[['start','end'],'format' => 'php:Y-m-d H:i:s'],
[['active'], 'integer'],
[['active'], 'in', 'range' => array_keys(self::$_CONDITIONS)],
];
}
}
Widget:
<?php DynamicFormWidget::begin([
'widgetContainer' => 'wrapper-prices',
'widgetBody' => '.container-items',
'widgetItem' => '.item',
'limit' => 30,
'min' => 1,
'insertButton' => '.add-item',
'deleteButton' => '.remove-item',
'model' => count($prices) ? $prices[0] : new appmodelsPrice(),
'template' => $this->render('_price-item', [
'i' => 0,
'form' => $form,
'model' => count($prices) ? $prices[0] : new appmodelsPrice(),
]),
'formId' => 'dynamic-form',
'formFields' => [
'credits',
'price',
'reduced_price',
'discount',
'start',
'end',
'active',
],
]); ?>
mysql:
CREATE TABLE `price` (
`id` int(11) NOT NULL,
`credits` int(11) NOT NULL,
`price` float NOT NULL,
`reduced_price` float DEFAULT NULL,
`discount` float DEFAULT NULL,
`start` datetime DEFAULT NULL,
`end` datetime DEFAULT NULL,
`active` smallint(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Can anybody tell me, what is wrong ?
my head almost burns
question from:
https://stackoverflow.com/questions/66068765/setting-unknown-property-yii-validators-numbervalidator0