Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select2 problem on nested #336

Open
MadSoul95 opened this issue Sep 26, 2023 · 0 comments
Open

Select2 problem on nested #336

MadSoul95 opened this issue Sep 26, 2023 · 0 comments

Comments

@MadSoul95
Copy link

Hi,

I'm currently working with a nested dynamicform where everytime I click on the add button the select2 its just empty
I tried with many forms to show it after the insert and the problem persist.

This just happen on the nested one, the others works perfectly fine

This is the code for the nested dynamicform:

'dynamicform_inner', 'widgetBody' => '.container-fibras', 'widgetItem' => '.fibras-item', 'min' => 1, 'insertButton' => '.add-fibras', 'deleteButton' => '.remove-fibras', 'model' => $fibrasReserva[0], 'formId' => 'dynamic-form', 'formFields' => [ 'description' ], ]); ?>
<table class="table table-bordered">
    <thead>
        <tr>
            <th>Detalle de Cortes</th>
            <th class="text-center">
                <button type="button" class="add-fibras btn btn-success btn-xs"><span class="glyphicon glyphicon-plus"></span></button>
            </th>
        </tr>
    </thead>
    <tbody class="container-fibras">
    <?php foreach ($fibrasReserva as $i => $fibra): ?>
        <tr class="fibras-item">
            <td class="vcenter">
                <div class="col-md-12">
                    <div class="col-md-4">
                        <label>Fibra Óptica</label>
                        <?= $form->field($fibra, "[{$i}]id_fibra")->widget(Select2::Classname(),[
                            'data' => '',
                            'language' => 'es',
                            'options' => [
                                'class' => 'oc-fibra selectFibras',
                                'placeholder' => 'Seleccione una Fibra...'
                            ],
                            'pluginOptions' => [
                                'allowClear' => true
                                ],
                            ])->label(false);
                        ?>
                    </div>
                    <div class="col-md-4">
                        <label>Distancia Origen</label>
                        <?= $form->field($fibra, "[{$i}]distancia_origen")->label(false)->textInput(['maxlength' => true]) ?>
                    </div>
                    <div class="col-md-4">
                        <label>Distancia Destino</label>
                        <?= $form->field($fibra, "[{$i}]distancia_destino")->label(false)->textInput(['maxlength' => true]) ?>
                    </div>
                </div>
            </td>
            <td class="text-center vcenter" style="width: 90px;">
                <button type="button" class="remove-fibras btn btn-danger btn-xs"><span class="glyphicon glyphicon-minus"></span></button>
            </td>
        </tr>
    <?php endforeach; ?>
    </tbody>
</table>

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant