Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何编辑前端地址表单-Prestashop_Php_Prestashop_Smarty - Fatal编程技术网

Php 如何编辑前端地址表单-Prestashop

Php 如何编辑前端地址表单-Prestashop,php,prestashop,smarty,Php,Prestashop,Smarty,我尝试使用下拉列表而不是“城市”字段的文本框。(如国家/地区列表)。我尝试编辑地址表单.tpl文件。但它包含smarty值。我不知道要编辑哪个.tpl/控制器 地址表.tpl <section class="form-fields"> {block name='form_fields'} {foreach from=$formFields item="field"} {block name='form_field'}

我尝试使用下拉列表而不是“城市”字段的文本框。(如国家/地区列表)。我尝试编辑
地址表单.tpl
文件。但它包含smarty值。我不知道要编辑哪个.tpl/控制器

地址表.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>

{block name='form_fields'}
{foreach from=$formFields item=“field”}
{block name='form_field'}
{form_field=$field}
{/block}
{/foreach}
{/block}

我终于找到了解决办法

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/\u 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>
{elseif$field.type==='citySelect'}
{l s='--请选择--'d='Shop.Forms.Labels'}
{foreach from=$field.availableValues item=“label”key=“value”}
{$label}
{/foreach}

我终于找到了解决办法

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/\u 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>
{elseif$field.type==='citySelect'}
{l s='--请选择--'d='Shop.Forms.Labels'}
{foreach from=$field.availableValues item=“label”key=“value”}
{$label}
{/foreach}

您真的想在一个下拉菜单中创建世界各地所有城市、村庄和定居点的详细列表吗?如果少了一个呢?您是否有其他文本字段?我有斯里兰卡的城市列表。我想在该城市下拉列表中显示它们。而且我的国家列表中只有斯里兰卡。好的,单一国家+城市列表是有意义的。在您的主题目录中看起来像
身份验证。tpl
您真的想创建所有城市的详细列表吗,全世界的村庄和定居点都在一个下拉菜单中?如果少了一个呢?您是否有其他文本字段?我有斯里兰卡的城市列表。我想在该城市下拉列表中显示这些城市。我的国家列表中也只有斯里兰卡。好的,单一国家+城市列表是有意义的。看起来像是主题目录中的
authentication.tpl