0
I’m using the widget https://github.com/unclead/yii2-multiple-input along with yii2 and I’m having an error at commit time.
My scenario is this: In my "catalogs" form the user can when creating the catalogue, create how many catalog items he wants to. That is, use in the catalog creation form the multi input widget to create various type records catalog items
I’m having the following mistake:
Code of my form:
<?= $form->field($model, 'mensagem2')->textInput(['maxlength' => true]) ?>
<?php
$models = Ponto_venda::find()->asArray()->all();
$map = ArrayHelper::map($models, 'id_ponto_v', function($model, $defaultValue) {return $model['nome'].' - ' .$model['descricao'];});
?>
<div class="row">
<div class="col-lg-11">
<?= $form->field($model, 'ponto_venda_id_ponto_v')->dropDownList($map) ?>
</div>
<div class="col-lg-1">
<a class="btn btn-primary" href="index.php?r=ponto_venda%2Fcreate" role="button" style="margin-top:25px;"><span class="glyphicon glyphicon-plus"></span></a>
</div>
</div>
<!-- Parte dos itens do catalogo -->
<?php
$item_models = Cerveja::find()->asArray()->all();
$item_map = ArrayHelper::map($item_models, 'id_cerveja', function($item, $defaultValue) {return $item['nome'].' - '.$item['marca_id_marca'];});
?>
<br/>
<?= $form->field($item, 'Item_catalogo')->widget(MultipleInput::className(), [
'max' => 4,
'columns' => [
[
'name' => 'cerveja_id_cerveja',
'type' => 'dropDownList',
'title' => 'Cerveja',
'items' =>$item_map
],
[
'name' => 'preco1',
'enableError' => true,
'title' => 'Preço1',
],
[
'name' => 'preco2',
'enableError' => true,
'title' => 'Preço2',
],
[
'name' => 'preco3',
'enableError' => true,
'title' => 'Preço3',
],
]
]);
?>
<!-- -->
I can not understand why the error to the commit of catalog items being that in the POST apparently everything respects the rules of integrity... I’m new to the framework... Thank you!
Thanks for answering, friend, but I ended up using this other widget https://github.com/wbraganca/yii2-dynamicform
– Bruno Carazato
The important thing is you solved it. Hugs!
– Lima Chaves
@Brunocarazato , I’m glad you solved it, but the problem there is not with wdget but with a foreign key in your database.
– rafaelvaloto