← All changes
|
app/Services/FluentConversational/Classes/Converter/Converter.php
+20
-2
6.2.14
→
trunk
View file →
| @@ -6,8 +6,9 @@ | ||
| 6 | 6 | |
| 7 | 7 | use FluentForm\App\Helpers\Helper; |
| 8 | 8 | use FluentForm\App\Modules\Payments\PaymentHelper; |
| 9 | 9 | use FluentForm\App\Modules\Component\Component; |
| 10 | +use FluentForm\App\Services\FormBuilder\AutocompleteTokens; | |
| 10 | 11 | use FluentForm\App\Services\FormBuilder\RatingIcon; |
| 11 | 12 | use FluentForm\App\Services\FormBuilder\Components\DateTime; |
| 12 | 13 | use FluentForm\App\Modules\Form\FormFieldsParser; |
| 13 | 14 | use FluentForm\Framework\Helpers\ArrayHelper; |
| @@ -201,8 +202,16 @@ | ||
| 201 | 202 | |
| 202 | 203 | if (!$hasSaveAndResume) { |
| 203 | 204 | $item['attributes']['value'] = self::setDefaultValue(ArrayHelper::get($item, 'attributes.value', ''), $item, $form);; |
| 204 | 205 | } |
| 206 | + // Per-sub-field token, resolved exactly as the classic renderer | |
| 207 | + // does, so both renderers agree on the same saved form. | |
| 208 | + $item['attributes']['autocomplete'] = ArrayHelper::get(AutocompleteTokens::normalizeAttributes(['autocomplete' => AutocompleteTokens::forSubField( | |
| 209 | + ArrayHelper::get($item, 'attributes.name'), | |
| 210 | + ArrayHelper::get($field, 'attributes.autocomplete'), | |
| 211 | + ArrayHelper::get($item, 'attributes.autocomplete') | |
| 212 | + )]), 'autocomplete'); | |
| 213 | + | |
| 205 | 214 | $question['fields'][] = wp_parse_args($itemQuestion, $item); |
| 206 | 215 | } |
| 207 | 216 | } |
| 208 | 217 | } elseif ('input_name' === $field['element']) { |
| @@ -232,8 +241,16 @@ | ||
| 232 | 241 | } |
| 233 | 242 | |
| 234 | 243 | $item['attributes']['value'] = self::getComponent()->replaceEditorSmartCodes(ArrayHelper::get($item, 'attributes.value'), $form); |
| 235 | 244 | |
| 245 | + // Per-sub-field token, resolved exactly as the classic renderer | |
| 246 | + // does, so both renderers agree on the same saved form. | |
| 247 | + $item['attributes']['autocomplete'] = ArrayHelper::get(AutocompleteTokens::normalizeAttributes(['autocomplete' => AutocompleteTokens::forSubField( | |
| 248 | + ArrayHelper::get($item, 'attributes.name'), | |
| 249 | + ArrayHelper::get($field, 'attributes.autocomplete'), | |
| 250 | + ArrayHelper::get($item, 'attributes.autocomplete') | |
| 251 | + )]), 'autocomplete'); | |
| 252 | + | |
| 236 | 253 | $question['fields'][] = wp_parse_args($itemQuestion, $item); |
| 237 | 254 | } |
| 238 | 255 | } |
| 239 | 256 | } elseif ('input_text' === $field['element']) { |
| @@ -295,9 +312,9 @@ | ||
| 295 | 312 | $question['searchable'] = ArrayHelper::get($field, 'settings.enable_select_2'); |
| 296 | 313 | } elseif ('dynamic_field' === $field['element']) { |
| 297 | 314 | $dynamicFetchValue = 'yes' == ArrayHelper::get($field, 'settings.dynamic_fetch'); |
| 298 | 315 | if ($dynamicFetchValue) { |
| 299 | - $field = apply_filters('fluentform/dynamic_field_re_fetch_result_and_resolve_value', $field); | |
| 316 | + $field = apply_filters('fluentform/dynamic_field_re_fetch_result_and_resolve_value', $field, $form->id); | |
| 300 | 317 | $question['answer'] = self::getComponent()->replaceEditorSmartCodes(ArrayHelper::get($field, 'attributes.value'), $form); |
| 301 | 318 | } |
| 302 | 319 | $type = ArrayHelper::get($field, 'settings.field_type', 'select'); |
| 303 | 320 | if (in_array($type, ['checkbox', 'radio'])) { |
| @@ -735,9 +752,9 @@ | ||
| 735 | 752 | } |
| 736 | 753 | } |
| 737 | 754 | } elseif ('payment_summary_component' === $field['element']) { |
| 738 | 755 | $question['title'] = self::getComponent()->replaceEditorSmartCodes(__('Payment Summary', 'fluentform'), $form); |
| 739 | - $question['emptyText'] = $field['settings']['cart_empty_text']; | |
| 756 | + $question['emptyText'] = fluentform_sanitize_html(ArrayHelper::get($field, 'settings.cart_empty_text', '')); | |
| 740 | 757 | } elseif ('net_promoter_score' === $field['element']) { |
| 741 | 758 | if (!ArrayHelper::exists($question, 'answer')) { |
| 742 | 759 | $question['answer'] = (int) $field['attributes']['value']; |
| 743 | 760 | } |
| @@ -967,8 +984,9 @@ | ||
| 967 | 984 | 'title' => self::getComponent()->replaceEditorSmartCodes(ArrayHelper::get($field, 'settings.label'), $form), |
| 968 | 985 | 'type' => ArrayHelper::get(static::fieldTypes(), $field['element']), |
| 969 | 986 | 'ff_input_type' => ArrayHelper::get($field, 'element'), |
| 970 | 987 | 'container_class' => ArrayHelper::get($field, 'settings.container_class'), |
| 988 | + 'autocomplete' => ArrayHelper::get(AutocompleteTokens::normalizeAttributes((array) ArrayHelper::get($field, 'attributes', [])), 'autocomplete'), | |
| 971 | 989 | 'placeholder' => self::getComponent()->replaceEditorSmartCodes(ArrayHelper::get($field, 'attributes.placeholder'), $form), |
| 972 | 990 | 'maxLength' => ArrayHelper::get($field, 'attributes.maxlength'), |
| 973 | 991 | 'required' => ArrayHelper::get($validationsRules, 'required.value'), |
| 974 | 992 | 'requiredMsg' => ArrayHelper::get($validationsRules, 'required.message'), |