app/Plugin/EccubePaymentLite42/Resource/template/admin/Product/regular_cycle_form.twig line 1

Open in your IDE?
  1. <script>
  2.     function changeRegularCycleForm(selectedSaleTypeId, regularSaleTypeId) {
  3.         if (selectedSaleTypeId === regularSaleTypeId) {
  4.             $('input[id^=admin_product_class_RegularCycle]').prop('disabled', false);
  5.         } else {
  6.             $('input[id^=admin_product_class_RegularCycle]').prop('disabled', true);
  7.         }
  8.     }
  9.     $(function() {
  10.         {# 定期サイクルフォームの追加 #}
  11.         $('#admin_product_class_delivery_duration').closest('#basicConfig > .card-body').append(
  12.             '<div class="row">' +
  13.                 '<div class="col-3">' +
  14.                     '<span>定期サイクル</span>' +
  15.                 '</div>' +
  16.                 '<div class="col mb-2">' +
  17.                     '<div id="admin_product_class_RegularCycle">' +
  18.                         {% for key, child in form.class.RegularCycle.vars.choices %}
  19.                         {% set Cycle = form.class.RegularCycle.vars.choices[key].data %}
  20.                         '<div class="form-check">' +
  21.                             '<input type="checkbox" id="admin_product_class_RegularCycle_{{ key }}" name="admin_product[class][RegularCycle][]" class="form-check-input" {% for key2, child2 in form.class.RegularCycle.vars.value %}{% if child2 == key %}checked="checked"{% endif %}{% endfor %} value="{{ key }}">' +
  22.                             '<label class="form-check-label" for="admin_product_class_RegularCycle_{{ key }}">{{ Cycle }}</label>' +
  23.                         '</div>' +
  24.                         {% endfor %}
  25.                     '</div>' +
  26.                     {% if form.class.RegularCycle.vars.errors|length > 0 %}
  27.                         {% for error in form.class.RegularCycle.vars.errors %}
  28.                             '<span class="invalid-feedback d-block">' +
  29.                                 '<span class="d-block">' +
  30.                                     '<span class="form-error-icon badge bg-danger text-uppercase">エラー</span> <span class="form-error-message">{{ error.message }}</span>' +
  31.                                 '</span>' +
  32.                             '</span>' +
  33.                         {% endfor %}
  34.                     {% endif %}
  35.                 '</div>' +
  36.             '</div>'
  37.         );
  38.         var regularSaleTypeId = '{{ regularSaleTypeId }}';
  39.         {# 定期サイクルフォーム初期読み込み時、使用可、不可を設定 #}
  40.         changeRegularCycleForm($('#admin_product_class_sale_type option:selected').val(), regularSaleTypeId);
  41.         {# 販売種別変更時に、定期サイクルフォームの使用可、不可を設定 #}
  42.         $('#admin_product_class_sale_type').on('change', function() {
  43.             var selectedSaleTypeId = $(this).val();
  44.             changeRegularCycleForm(selectedSaleTypeId, regularSaleTypeId);
  45.         });
  46.     });
  47. </script>