Advertisement
pmtpenza

Untitled

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