问题
I'm trying to use drop down list instead of textbox for 'City' field.(Like country list).I tried to edit address-form.tpl
file.but it's contain smarty values.I don't know which .tpl/Controller i want to edit.
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:
finally i got a solution
1) add form type to city field
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) edit .tpl file
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>
来源:https://stackoverflow.com/questions/49248651/how-to-edit-front-address-form-prestashop