Opencart 3.x JournalTheme показать / скрыть радиокнопки в форме реестра - PullRequest
0 голосов
/ 30 мая 2019

В форме реестра есть возможность показать или скрыть поля после нажатия кнопки переключателя группы клиентов.Однако это работает только в стандартном шаблоне opencart, а не в Journaltheme.

Я проверил файл .twig по умолчанию, но не могу найти никакой разницы между сценарием.Я должен сказать, что я новичок.Не знаю насчет скриптов.Я спросил строителей Journaltheme, они сказали, что это невозможно.

Запуски: php версия 7.1 Apache-версия 2.4.39 CLOUDLINUX 7,6 квм

Это в файле ветки:

    <fieldset id="account">
      <legend>{{ text_your_details }}</legend>
      <div class="form-group required" style="display: {{ customer_groups|length > 1 ? 'block' : 'none' }};">
        <label class="col-sm-2 control-label">{{ entry_customer_group }}</label>

        <div class="col-sm-10">{% for customer_group in customer_groups %}
              {% if customer_group.customer_group_id == customer_group_id %}
                <div class="radio">
                  <label>
                    <input type="radio" name="customer_group_id" value="{{ customer_group.customer_group_id }}" checked="checked"/>
                    {{ customer_group.name }}</label>
                </div>
              {% else %}
                <div class="radio">
                  <label>
                    <input type="radio" name="customer_group_id" value="{{ customer_group.customer_group_id }}"/>
                    {{ customer_group.name }}</label>
                </div>
              {% endif %}
            {% endfor %}</div>
        </div>

скрипт:

$ ('input [name = \' customer_group_id \ ']'). On ('change', function () {$ .ajax ({url: 'index.php? route = account / advanceregister / customfield & customer_group_id =' + this.value, dataType: 'json', success: function (json) {$ ('. custom-field'). hide (); $ ('.custom-field '). removeClass (' обязательный ');

  for (i = 0; i < json.length; i++) {
    custom_field = json[i];

    $('#custom-field' + custom_field['custom_field_id']).show();

    if (custom_field['required']) {
      $('#custom-field' + custom_field['custom_field_id']).addClass('required');
    }
  }


},
error: function(xhr, ajaxOptions, thrownError) {
  alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}

});});

$ (' input [name = \ 'customer_group_id \']: проверено') .trigger (' change ');

Я хочу, чтобы, если установлен переключатель 1, показывалось поле, отображаемое в бэкэнде opencart для показа.

И он будет прятаться, когда я проверяю кнопку радио 2.

...