Hi,
I use two modules in one form: Dropzone and DynamicForm.
It works ok, but there is one problem. When I use them at the same time it does not work the remove button in the DynamicForm. I dont know how to fix it.
My code (_form.php):
<div class="panel panel-default">
<div class="panel-heading"><h4><i class="glyphicon glyphicon-film"></i> Films</h4></div>
<div class="panel-body">
<?php DynamicFormWidget::begin([
'widgetContainer' => 'dynamicform_wrapper', // required: only alphanumeric characters plus "_" [A-Za-z0-9_]
'widgetBody' => '.container-items', // required: css class selector
'widgetItem' => '.item', // required: css class
'limit' => 8, // the maximum times, an element can be cloned (default 999)
'min' => 1, // 0 or 1 (default 1)
'insertButton' => '.add-item', // css class
'deleteButton' => '.remove-item', // css class
'model' => $filmy[0],
'formId' => 'dynamic-form',
'formFields' => [
'film',
],
]); ?>
<div class="container-items"><!-- widgetContainer -->
<?php foreach ($filmy as $i => $film): ?>
<div class="item panel panel-default"><!-- widgetBody -->
<div class="panel-body">
<?php
// necessary for update action.
if (! $film->isNewRecord) {
echo Html::activeHiddenInput($film, "[{$i}]id");
}
?>
<div class="pull-right">
<button type="button" class="add-item btn btn-success btn-xs">
<i class="glyphicon glyphicon-plus"></i></button>
<button type="button" class="remove-item btn btn-danger btn-xs">
<i class="glyphicon glyphicon-minus"></i></button>
</div><?= $form->field($film, "[{$i}]film")->textInput(['maxlength' => true]) ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php DynamicFormWidget::end(); ?>
</div>
</div>
<div id="gallery">
<h4>Photo gallery</h4>
<?php
echo \kato\DropZone::widget([
'options' => [
'addRemoveLinks' => 'Remove image',
'url' => 'index.php?r=ogloszenia/gallery',
'maxFilesize' => '5',
'acceptedFiles' => 'image/jpg, image/jpeg, image/png, image/gif',
],
'clientEvents' => [
'id' => 'nowy',
'complete' => "function(file){console.log(file)}",
'removedfile' => "function(file){alert(file.name + ' is removed')}"
],
]);
?>