modalform.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\jui\DatePicker;
  4. use kartik\datetime\DateTimePicker;
  5. use yii\web\JsExpression;
  6. use yii\web\View;
  7. use yii\widgets\ActiveForm;
  8. use app\models\base\TopSlider;
  9. $model = new TopSlider();
  10. /* @var $this yii\web\View */
  11. /* @var $model app\models\base\TopSlider */
  12. /* @var $form yii\widgets\ActiveForm */
  13. ?>
  14. <div class="modal" tabindex="-1" data-show="false" id="modalcsl" data-backdrop="static" data-keyboard="false">
  15. <div class="modal-dialog modal-lg">
  16. <div class="modal-content">
  17. <div class="modal-header">
  18. <h5 class="modal-title">Коммерческий слайдер</h5>
  19. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  20. <span aria-hidden="true">&times;</span>
  21. </button>
  22. </div>
  23. <div class="modal-body">
  24. <div class="top-slider-form">
  25. <?php $formsl = ActiveForm::begin([
  26. 'id' => 'TopSlider',
  27. 'action' => 'AjaxSave',
  28. 'enableAjaxValidation' => false,
  29. // 'validationUrl' => 'validation-rul',
  30. ]); ?>
  31. <input type="hidden" name="TopSlider[post_id]" value="<?=$news->id?>">
  32. <div class="row">
  33. <div class="col-md-6">
  34. <?= $formsl->field($model, 'published_from')->widget(DateTimePicker::classname(), [
  35. 'name' => 'published_from',
  36. 'options' => ['class' => 'form-control'],
  37. 'convertFormat' => true,
  38. 'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
  39. 'pluginOptions' => [
  40. 'format' => 'yyyy-MM-dd hh:i:s',
  41. 'startDate' => '2023-01-01 12:00',
  42. 'todayHighlight' => true,
  43. 'autoclose'=>true
  44. ]
  45. ])?>
  46. </div>
  47. <div class="col-md-6">
  48. <?= $formsl->field($model, 'published_to')->widget(DateTimePicker::classname(), [
  49. 'name' => 'published_to',
  50. 'options' => ['class' => 'form-control'],
  51. 'convertFormat' => true,
  52. 'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
  53. 'pluginOptions' => [
  54. 'format' => 'yyyy-MM-dd hh:i:s',
  55. 'startDate' => '2023-01-01 12:00',
  56. 'todayHighlight' => true,
  57. 'autoclose'=>true
  58. ]
  59. ])?>
  60. </div>
  61. </div>
  62. <?= $formsl->field($model, 'is_active')->checkbox() ?>
  63. <div class="form-group">
  64. <a href="javascript:senddata();" class="btn btn-success">Сохранить</a>
  65. </div>
  66. <?php ActiveForm::end(); ?>
  67. </div>
  68. </div>
  69. <div class="modal-footer">
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. <script>
  75. function senddata(){
  76. var form = $('#TopSlider');
  77. // console.log(form);
  78. $.getJSON( "/manager/top-slider/ajaxsave", form.serialize(), function( json ){
  79. console.log(json);
  80. if( json.success == 'err' ){
  81. alert(json.err);
  82. }
  83. } );
  84. }
  85. </script>