如何编辑地址前置表-Prestashop [英] How to edit Front Address form - Prestashop

查看:40
本文介绍了如何编辑地址前置表-Prestashop的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用"City"字段的下拉列表而不是文本框。(如"Country List")。我尝试编辑address-form.tpl文件。但它包含智能值。我不知道要编辑哪个.tpl/Controller。

address-form.tpl

<section class="form-fields">
      {block name='form_fields'}
        {foreach from=$formFields item="field"}
          {block name='form_field'}
            {form_field field=$field}
          {/block}
        {/foreach}
      {/block}
    </section>

推荐答案

最终我得到了解决方案

1)将表单类型添加到城市字段 classes/form/CustomerAddressFormatter.php

if ($field === 'city') {
                    $formField->setType('select');
                    $formField->setType('citySelect');
                    $formField->setRequired(true);

                    $loc=new Location();         //load data from db
                    $result=$loc->getLocations();

                    foreach ($result as $value) {
                        $formField->addAvailableValue(
                            $value['area'],
                            $value['area']
                        );
                    }
            }
2)编辑.tpl文件 themes/yourtheme/templates/_partials/form-fields.tpl

{elseif $field.type === 'citySelect'}

          <select
            class="form-control form-control-select chosen-select"
            name="{$field.name}"
            {if $field.required}required{/if}
          >
            <option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
            {foreach from=$field.availableValues item="label" key="value"}
              <option value="{$value}" {if $value eq $field.value} selected {/if}>{$label}</option>
            {/foreach}
          </select>

这篇关于如何编辑地址前置表-Prestashop的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆