| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentForm\App\Services\FormBuilder\Components; |
| 4 | 4 | |
| 5 | +use FluentForm\App\Services\FormBuilder\AutocompleteTokens; | |
| 5 | 6 | use FluentForm\App\Helpers\Helper; |
| 6 | 7 | use FluentForm\Framework\Helpers\ArrayHelper; |
| 7 | 8 | use FluentForm\App\Services\FormBuilder\Components\Select; |
| 8 | 9 | |
| @@ -45,10 +46,11 @@ | ||
| 45 | 46 | $data['attributes']['class'] .= ' ff-field_container ff-name-field-wrapper'; |
| 46 | 47 | if ($containerClass = ArrayHelper::get($data, 'settings.container_class')) { |
| 47 | 48 | $data['attributes']['class'] .= ' ' . $containerClass; |
| 48 | 49 | } |
| 50 | + // autocomplete belongs to the sub-fields, not to this wrapper <div>. | |
| 49 | 51 | $atts = $this->buildAttributes( |
| 50 | - ArrayHelper::except($data['attributes'], 'name') | |
| 52 | + ArrayHelper::except($data['attributes'], ['name', 'autocomplete']) | |
| 51 | 53 | ); |
| 52 | 54 | |
| 53 | 55 | $html = "<div {$atts}>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $atts is escaped before being passed in. |
| 54 | 56 | $html .= "<div class='ff-t-container'>"; |
| @@ -63,8 +65,14 @@ | ||
| 63 | 65 | foreach ($data['fields'] as $field) { |
| 64 | 66 | if ($field['settings']['visible']) { |
| 65 | 67 | $fieldName = $field['attributes']['name']; |
| 66 | 68 | $field['attributes']['name'] = $rootName . '[' . $fieldName . ']'; |
| 69 | + | |
| 70 | + $field['attributes']['autocomplete'] = AutocompleteTokens::forSubField( | |
| 71 | + $fieldName, | |
| 72 | + ArrayHelper::get($data, 'attributes.autocomplete'), | |
| 73 | + ArrayHelper::get($field, 'attributes.autocomplete') | |
| 74 | + ); | |
| 67 | 75 | @$field['attributes']['class'] = trim( |
| 68 | 76 | 'ff-el-form-control ' . |
| 69 | 77 | $field['attributes']['class'] |
| 70 | 78 | ); |