Автор: Wanderson Bragança (wanderson.wbc@gmail.com)
Наследование: extends yii\base\Widget
Пример #1
0
    /**
     * @param \wbraganca\dynamicform\View $view
     */
    public function registerAssets($view)
    {
        parent::registerAssets($view);
        // For init select2
        $view->registerJs(<<<JS
            \$('.{$this->widgetContainer}').on('afterInsert', function(e, item) {
                var options = eval(\$(this).data('dynamicform'));
                var combos = \$(item).find('[data-combo-field]');
                if (combos.length > 0) {
                    combos.each(function() {
                        var comboItem = this;
                        var template = \$('.' + options.widgetContainer).find(options.widgetItem).first().find('[data-combo-field]').filter(function () {
                            return \$(this).data('combo-field') == \$(comboItem).data('combo-field');
                        });

                        if (template.length == 0) {
                            return true;
                        }

                        var config_id = \$(template[0]).data('field').id;
                        \$(item).closest(options.widgetItem).combo().register(\$(this), config_id);
                    });
                }
            });
JS
);
        // For init datetime picker
        $view->registerJs(<<<JS
            \$('.{$this->widgetContainer}').on('afterInsert', function(e, item) {
                var options = eval(\$(this).data('dynamicform'));
                var pickers = \$(item).find('[data-krajee-datetimepicker]');
                if (pickers.length > 0) {
                    pickers.each(function() {
                        var pickerItem = this;
                        var template = \$('.' + options.widgetContainer).find(options.widgetItem).first().find('[data-krajee-datetimepicker]').filter(function () {
                            return \$(this).data('krajee-datetimepicker') == \$(pickerItem).data('krajee-datetimepicker');
                        });

                        if (template.length == 0) {
                            return true;
                        }

                        var config_id = \$(template[0]).data('krajee-datetimepicker');
                        var elementId = \$(pickerItem).attr('id');
                        \$('#' + elementId + '-datetime').datetimepicker(config_id);
                    });
                }
            });
JS
);
    }
Пример #2
0
    ?>
                            </div>
                            <div class="col-sm-6">
                                <?php 
    echo $form->field($modelBitacora, "[{$i}]observacion")->textInput(['maxlength' => true]);
    ?>
                            </div>
                        </div><!-- .row -->
                    </div>
                </div>
            <?php 
}
?>
            </div>
            <?php 
DynamicFormWidget::end();
?>
        </div>
    </div>
    </div>


    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Crear' : 'Actualizar', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Пример #3
0
                        <?php 
    $group = $groupProperty['group'];
    if (!$group->isNewRecord) {
        echo Html::activeHiddenInput($group, "[{$i}]id");
    }
    ?>
                        <div class="row">
                            <div class="col-sm-5">
                                <?php 
    echo $form->field($group, "[{$i}]name")->textInput(['maxlength' => true]);
    ?>
                            </div>
                        </div>

                        <?php 
    $propertyWidget = DynamicFormWidget::begin(['widgetContainer' => "property_dynamic_form_{$i}", 'widgetBody' => ".properties-container", 'widgetItem' => ".property-panel-body", 'insertButton' => '.property-button-add', 'deleteButton' => '.property-button-remove', 'model' => new \common\models\Property(), 'formId' => 'category-form', 'formFields' => ['name', 'unit', 'filter_type']]);
    ?>

                        <div class="container-items"><!-- widgetContainer -->
                            <div class="property-item panel panel-default"><!-- widgetBody -->
                                <div class="panel-heading">
                                    <h3 class="panel-title pull-left">Properties</h3>
                                    <div class="pull-right">
                                        <button type="button" class="property-button-add btn btn-primary btn-xs"><i class="glyphicon glyphicon-plus"></i></button>
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                                <div class="properties-container">
                                    <?php 
    foreach ($groupProperty['properties'] as $nestedI => $property) {
        ?>