yii2-multiple-input icon indicating copy to clipboard operation
yii2-multiple-input copied to clipboard

using 2 model in 1 form error message not showing

Open dayatfadila7 opened this issue 5 years ago • 3 comments

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

dayatfadila7 avatar Jul 26 '19 07:07 dayatfadila7

post an example of the code to reproduce the issue

unclead avatar Jul 26 '19 08:07 unclead

*)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 Screen Shot 2019-07-26 at 23 07 29

dayatfadila7 avatar Jul 26 '19 16:07 dayatfadila7

do you use ajax validation? show your controller code as well

unclead avatar Jul 28 '19 08:07 unclead