pmtpenza

Untitled

Jun 26th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. <?php
  2.  
  3. use yii\helpers\Html;
  4. use yii\widgets\ActiveForm;
  5. use backend\models\Category;
  6. use wbraganca\dynamicform\DynamicFormWidget;
  7.  
  8. /* @var $this yii\web\View */
  9. /* @var $model backend\models\Zayvki */
  10. /* @var $form yii\widgets\ActiveForm */
  11. $js = '
  12.  
  13. jQuery(".dynamicform_wrapper").on("afterInsert", function(e, item) {
  14.  
  15. jQuery(".dynamicform_wrapper .panel-title-order").each(function(index) {
  16.  
  17. jQuery(this).html("Услуга: " + (index + 1))
  18.  
  19. });
  20.  
  21. });
  22.  
  23.  
  24. jQuery(".dynamicform_wrapper").on("afterDelete", function(e) {
  25.  
  26. jQuery(".dynamicform_wrapper .panel-title-address").each(function(index) {
  27.  
  28. jQuery(this).html("Address: " + (index + 1))
  29.  
  30. });
  31.  
  32. });
  33.  
  34. ';
  35.  
  36.  
  37. $this->registerJs($js);
  38. ?>
  39.  
  40. <div class="zayvki-form">
  41.  
  42. <?php $form = ActiveForm::begin(['id' => 'dynamic-form']); ?>
  43.  
  44. <?= $form->field($model, 'user_id')->textInput() ?>
  45.  
  46. <?php DynamicFormWidget::begin([
  47.  
  48.  
  49. 'widgetContainer' => 'dynamicform_wrapper', // required: only alphanumeric characters plus "_" [A-Za-z0-9_]
  50.  
  51. 'widgetBody' => '.container-items', // required: css class selector
  52.  
  53. 'widgetItem' => '.item', // required: css class
  54.  
  55. 'limit' => 999, // the maximum times, an element can be cloned (default 999)
  56.  
  57. 'min' => 0, // 0 or 1 (default 1)
  58.  
  59. 'insertButton' => '.add-item', // css class
  60.  
  61. 'deleteButton' => '.remove-item', // css class
  62.  
  63. 'model' => $orders[0],
  64.  
  65. 'formId' => 'dynamic-form',
  66.  
  67. 'formFields' => [
  68. 'category_id',
  69.  
  70. 'uslugi_id',
  71. ],
  72.  
  73. ]); ?>
  74. <div class="panel panel-default">
  75. <div class="panel-heading">
  76. <i class="fa fa-envelope"></i> Выбор услуг
  77. <button type="button" class="pull-right add-item btn btn-success btn-xs"><i class="fa fa-plus"></i> Добавить услугу</button>
  78. <div class="clearfix"></div>
  79. </div>
  80. <div class="panel-body container-items"><!-- widgetContainer -->
  81. <?php foreach ($orders as $index => $order): ?>
  82. <div class="item panel panel-default"><!-- widgetBody -->
  83. <div class="panel-heading">
  84. <span class="panel-title-address">Услуга <?= ($index + 1) ?></span>
  85. <button type="button" class="pull-right remove-item btn btn-danger btn-xs"><i class="fa fa-minus"></i></button>
  86. <div class="clearfix"></div>
  87. </div>
  88. <div class="panel-body">
  89. <?php
  90. // necessary for update action.
  91. if (!$order->isNewRecord) {
  92. echo Html::activeHiddenInput($order, "[{$index}]id");
  93. }
  94. ?>
  95. <?= $form->field($order, "[{$index}]category_id")->textInput(['maxlength' => true]) ?>
  96.  
  97. <div class="row">
  98. <div class="col-sm-6">
  99. <?= $form->field($order, "[{$index}]uslugi_id")->textInput(['maxlength' => true]) ?>
  100. </div>
  101. </div><!-- end:row -->
  102. </div>
  103. </div>
  104. <?php endforeach; ?>
  105. </div>
  106. </div>
  107. <?php DynamicFormWidget::end(); ?>
  108.  
  109.  
  110. <?= $form->field($model, 'status')->textInput() ?>
  111.  
  112. <?= $form->field($model, 'master')->textInput() ?>
  113.  
  114. <?= $form->field($model, 'uk')->textInput() ?>
  115.  
  116.  
  117. <div class="form-group">
  118. <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
  119. </div>
  120.  
  121. <?php ActiveForm::end(); ?>
  122.  
  123. </div>
Advertisement
Add Comment
Please, Sign In to add comment