yii2-multiple-input
yii2-multiple-input copied to clipboard
using 2 model in 1 form error message not showing
Hello Eugene Tupikov i'm using 2 model
model1 => normal form using default yii2 model2=>using yii2-mutiple-input ,
on model 1 i can show error message but model 2 not showing
i create 2 model in 1 form yii2
post an example of the code to reproduce the issue
*)this is my form
` = $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'address')->textInput() ?>
<?= $form->field($unitModel, 'unit')->widget(MultipleInput::className(), [
'columns' => [
[
'name' => 'name',
'title' => 'Nama',
'enableError' => true,
'options' => [
'class' => 'input-name'
]
],
[
'name' => 'capacity',
'title' => 'Kapasitas',
'enableError' => true,
'options' => [
'class' => 'input-capacity'
]
],
[
'name' => 'feed_stock',
'title' => 'Stok Pakan',
'enableError' => true,
'options' => [
'class' => 'input-feed_stock'
]
]
]
]); `
) farm model `/* * {@inheritdoc} */ public static function tableName() { return 'farms'; }
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['user_id', 'name', 'address'], 'required'],
[['user_id', 'status', 'is_deleted'], 'integer'],
[['address'], 'string'],
[['created_at', 'updated_at'], 'safe'],
[['name'], 'string', 'max' => 255],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => Yii::t('app', 'ID'),
'user_id' => Yii::t('app', 'User ID'),
'name' => Yii::t('app', 'Name'),
'address' => Yii::t('app', 'Address'),
'status' => Yii::t('app', 'Status'),
'created_at' => Yii::t('app', 'Created At'),
'updated_at' => Yii::t('app', 'Updated At'),
'is_deleted' => Yii::t('app', 'Is Deleted'),
];
}`
*) unit farm model `public static function tableName() { return 'unit_farms'; }
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name', 'farm_id', 'capacity'], 'required'],
[['farm_id', 'capacity', 'feed_stock', 'status', 'is_deleted'], 'integer'],
[['created_at', 'updated_at'], 'safe'],
[['name'], 'string', 'max' => 255],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => Yii::t('app', 'ID'),
'name' => Yii::t('app', 'Name'),
'farm_id' => Yii::t('app', 'Farm ID'),
'capacity' => Yii::t('app', 'Capacity'),
'feed_stock' => Yii::t('app', 'Feed Stock'),
'status' => Yii::t('app', 'Status'),
'created_at' => Yii::t('app', 'Created At'),
'updated_at' => Yii::t('app', 'Updated At'),
'is_deleted' => Yii::t('app', 'Is Deleted'),
];
}`
*) view form
do you use ajax validation? show your controller code as well