title: Upload widget does not work - Dynamic form Yii2 starter kit
body: <p>iam using the widget (trntv\filekit\widget \ Upload) of yii2-starter-kit, implement the use of the dynamic form (wbraganca\dynamicform\DynamicFormWidget), the problem is that the upload widget works only on the first element, when adding Other items fail to load correctly</p>
  <p>_form</p>
  
  <pre><code>&lt;?php $form = ActiveForm::begin(['id' =&gt; 'dynamic-form']); ?&gt;
  
  &lt;div class=&quot;row&quot;&gt;
  
      &lt;div class=&quot;col-sm-6&quot;&gt;
  
          &lt;?= $form-&gt;field($model, 'title')-&gt;textInput(['maxlength' =&gt; true]) ?&gt;
  
  
          &lt;?php echo $form-&gt;field($model, 'category_id')-&gt;dropDownList(\yii\helpers\ArrayHelper::map(
              $categories,
              'id',
              'name'
          ), ['prompt' =&gt; '']) ?&gt;
  
  
  
          &lt;?= $form-&gt;field($model, 'amount')-&gt;textInput() ?&gt;
  
          &lt;?= $form-&gt;field($model, 'delivery_charge')-&gt;textInput() ?&gt;
  
          &lt;?php echo $form-&gt;field($model, 'description')-&gt;widget(
              \yii\imperavi\Widget::class,
              [
                  'plugins' =&gt; ['fullscreen', 'fontcolor', 'video'],
                  'options' =&gt; [
                      'minHeight' =&gt; 200,
                      'maxHeight' =&gt; 200,
                      'buttonSource' =&gt; true,
                      'convertDivs' =&gt; false,
                      'removeEmptyTags' =&gt; true,
                      'imageUpload' =&gt; Yii::$app-&gt;urlManager-&gt;createUrl(['/file/storage/upload-imperavi']),
                  ],
              ]
          ) ?&gt;
  
  
      &lt;/div&gt;
  
      &lt;div class=&quot;col-md-6&quot;&gt;
  
          &lt;?php echo $form-&gt;field($model, 'attachments')-&gt;widget(
              Upload::class,
              [
                  'url' =&gt; ['/file/storage/upload'],
                  'maxFileSize' =&gt; 5000000, // 5 MiB,
                  'acceptFileTypes' =&gt; new JsExpression('/(\.|\/)(gif|jpe?g|png)$/i'),
              ]
          );
          ?&gt;
  
          &lt;?= $form-&gt;field($model, 'availability')-&gt;widget(SwitchInput::className()); ?&gt;
  
          &lt;?= $form-&gt;field($model, 'status')-&gt;dropDownList(\common\models\Product::statuses()) ?&gt;
  
  
  
          &lt;?php echo $form-&gt;field($model, 'features')-&gt;widget(
              \yii\imperavi\Widget::class,
              [
                  'plugins' =&gt; ['fullscreen', 'fontcolor', 'video'],
                  'options' =&gt; [
                      'minHeight' =&gt; 200,
                      'maxHeight' =&gt; 200,
                      'buttonSource' =&gt; true,
                      'convertDivs' =&gt; false,
                      'removeEmptyTags' =&gt; true,
                      'imageUpload' =&gt; Yii::$app-&gt;urlManager-&gt;createUrl(['/file/storage/upload-imperavi']),
                  ],
              ]
          ) ?&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
  
  
  &lt;div class=&quot;row&quot;&gt;
  
      &lt;div class=&quot;col-md-10&quot;&gt;
  
          &lt;?php DynamicFormWidget::begin([
              'widgetContainer' =&gt; 'dynamicform_wrapper', // required: only alphanumeric characters plus &quot;_&quot; [A-Za-z0-9_]
              'widgetBody' =&gt; '.container-items', // required: css class selector
              'widgetItem' =&gt; '.item', // required: css class
              'limit' =&gt; 10, // the maximum times, an element can be cloned (default 999)
              'min' =&gt; 1, // 0 or 1 (default 1)
              'insertButton' =&gt; '.add-item', // css class
              'deleteButton' =&gt; '.remove-item', // css class
              'model' =&gt; $modelsIngredient[0],
              'formId' =&gt; 'dynamic-form',
              'formFields' =&gt; [
                  'title',
                  'description',
                  'image',
                  'featured_base_url',
                  'featured_path'
              ],
          ]); ?&gt;
          &lt;div class=&quot;panel panel-default&quot;&gt;
              &lt;div class=&quot;panel-heading&quot;&gt;
                  &lt;i class=&quot;fa fa-folder&quot;&gt;&lt;/i&gt; Product Ingredients
                  &lt;button type=&quot;button&quot; class=&quot;pull-right add-item btn btn-success btn-xs&quot;&gt;&lt;i class=&quot;fa fa-plus&quot;&gt;&lt;/i&gt; Add
                  &lt;/button&gt;
                  &lt;div class=&quot;clearfix&quot;&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;panel-body container-items&quot;&gt;
                  &lt;!-- widgetContainer --&gt;
                  &lt;?php foreach ($modelsIngredient
  
                      as $index =&gt; $modelIngredient) : ?&gt;
                      &lt;div class=&quot;item panel panel-default&quot;&gt;
                          &lt;!-- widgetBody --&gt;
                          &lt;div class=&quot;panel-heading&quot;&gt;
                              &lt;span class=&quot;panel-title-address&quot;&gt;Ingredients: &lt;?= ($index + 1) ?&gt;&lt;/span&gt;
                              &lt;button type=&quot;button&quot; class=&quot;pull-right remove-item btn btn-danger btn-xs&quot;&gt;&lt;i class=&quot;fa fa-minus&quot;&gt;&lt;/i&gt;&lt;/button&gt;
                              &lt;div class=&quot;clearfix&quot;&gt;&lt;/div&gt;
                          &lt;/div&gt;
                          &lt;div class=&quot;panel-body&quot;&gt;
                              &lt;?php
                              // necessary for update action.
                              if (!$modelIngredient-&gt;isNewRecord) {
                                  echo Html::activeHiddenInput($modelIngredient, &quot;[{$index}]id&quot;);
                              }
                              ?&gt;
  
                              &lt;div class=&quot;col-md-12&quot;&gt;
  
                                  &lt;?php echo $form-&gt;field($modelIngredient, &quot;[{$index}]title&quot;)-&gt;textInput(); ?&gt;
  
                              &lt;/div&gt;
  
                              &lt;div class=&quot;col-md-12&quot;&gt;
                                  
  
                                  &lt;?php echo $form-&gt;field($modelIngredient, &quot;[{$index}]image&quot;)-&gt;widget(
                                      Upload::class,
                                      [
                                          'url' =&gt; ['/file/storage/upload'],
                                          'maxFileSize' =&gt; 5000000, // 5 MiB,
                                          'acceptFileTypes' =&gt; new JsExpression('/(\.|\/)(gif|jpe?g|png)$/i'),
                                      ]
                                  );
                                  ?&gt;
  
                              &lt;/div&gt;
  
                              &lt;div class=&quot;col-md-12&quot;&gt;
  
  
                              &lt;?php echo $form-&gt;field($modelIngredient, &quot;[{$index}]description&quot;)-&gt;textarea(); ?&gt;
  
                  
  
                              &lt;/div&gt;
  
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;?php endforeach; ?&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;?php DynamicFormWidget::end(); ?&gt;
  
      &lt;/div&gt;
  
    &lt;/div&gt;
  
  
    &lt;/div&gt;
  
  
   &lt;div class=&quot;form-group&quot;&gt;
      
  
    &lt;?= Html::submitButton($model-&gt;isNewRecord ? 'Create' : 'Update',    ['class'=&gt;'btnbtnprimary'])      ?&gt;
   
  
   &lt;/div&gt;
  
  &lt;?php ActiveForm::end(); 
  
  
     $js = '
      jQuery(&quot;.dynamicform_wrapper&quot;).on(&quot;afterInsert&quot;, function(e, item) {
  
      jQuery(&quot;.dynamicform_wrapper .panel-title-address&quot;).each(function(index) {
  
      jQuery(this).html(&quot;Ingredients: &quot; + (index + 1))
      });
      });
  
     jQuery(&quot;.dynamicform_wrapper&quot;).on(&quot;afterDelete&quot;, function(e) {
     jQuery(&quot;.dynamicform_wrapper .panel-title-address&quot;).each(function(index) {
     jQuery(this).html(&quot;Ingredients: &quot; + (index + 1))
     });
     });
    ';
  
  
  
  
     $this-&gt;registerJs($js);
     ?&gt;
  </code></pre>
  <p>only first one is working the second one not working the value get null in controller.also second one css and js also not working.</p>
  <p><a href="https://i.stack.imgur.com/LSLvW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LSLvW.png" alt="enter image description here" /></a></p>