Advertisement
pmtpenza

Untitled

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