| @@ -2,8 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace FluentForm\App\Services\FormBuilder\Components; |
| 4 | 4 | |
| 5 | 5 | use FluentForm\App\Helpers\Helper; |
| 6 | +use FluentForm\App\Services\FormBuilder\AutocompleteTokens; | |
| 6 | 7 | use FluentForm\Framework\Helpers\ArrayHelper; |
| 7 | 8 | |
| 8 | 9 | class Address extends BaseComponent |
| 9 | 10 | { |
| @@ -71,10 +72,11 @@ | ||
| 71 | 72 | $data['attributes']['data-name'] = $data['attributes']['name']; |
| 72 | 73 | do_action('fluentform/address_map_autocomplete', $data, $form); |
| 73 | 74 | } |
| 74 | 75 | |
| 76 | + // autocomplete belongs to the sub-fields, not to this wrapper <div>. | |
| 75 | 77 | $atts = $this->buildAttributes( |
| 76 | - ArrayHelper::except($data['attributes'], 'name') | |
| 78 | + ArrayHelper::except($data['attributes'], ['name', 'autocomplete']) | |
| 77 | 79 | ); |
| 78 | 80 | |
| 79 | 81 | //re order fields from version 4.3.2 |
| 80 | 82 | if ($order = ArrayHelper::get($data, 'settings.field_order')) { |
| @@ -114,8 +116,14 @@ | ||
| 114 | 116 | if ($item['settings']['visible']) { |
| 115 | 117 | $itemName = $item['attributes']['name']; |
| 116 | 118 | $item['attributes']['data-key_name'] = $itemName; |
| 117 | 119 | $item['attributes']['name'] = $rootName . '[' . $itemName . ']'; |
| 120 | + | |
| 121 | + $item['attributes']['autocomplete'] = AutocompleteTokens::forSubField( | |
| 122 | + $itemName, | |
| 123 | + ArrayHelper::get($data, 'attributes.autocomplete'), | |
| 124 | + ArrayHelper::get($item, 'attributes.autocomplete') | |
| 125 | + ); | |
| 118 | 126 | |
| 119 | 127 | if ('select_country' === $item['element'] && $googleAutoComplete) { |
| 120 | 128 | $selectedCountries = (array) ArrayHelper::get($item, 'attributes.value', []); |
| 121 | 129 | if ('visible_list' === ArrayHelper::get($item, 'settings.country_list.active_list')) { |