← All changes
|
includes/Frontend/Form/View/Conversational/Fields/TextField.php
+43
-45
2.10.0
→
3.3.1
View file →
| @@ -18,70 +18,68 @@ | ||
| 18 | 18 | $fieldHelpers = new ConversationalFieldHelpers($formID, $field, $rowID, $form_atomic_Cls_map); |
| 19 | 19 | |
| 20 | 20 | $prefixIcn = $fieldHelpers->icon('prefixIcn', 'pre-i'); |
| 21 | 21 | $suffixIcn = $fieldHelpers->icon('suffixIcn', 'suf-i'); |
| 22 | - $sugg = ''; | |
| 23 | 22 | $req = $fieldHelpers->required(); |
| 24 | 23 | $disabled = $fieldHelpers->disabled(); |
| 25 | 24 | $readonly = $fieldHelpers->readonly(); |
| 26 | - $inputMode = ''; | |
| 25 | + $inputMode = apply_filters('bitform_field_inputmode_attr', '', $field); | |
| 27 | 26 | $name = $fieldHelpers->name(); |
| 28 | 27 | $ac = $fieldHelpers->autocomplete(); |
| 29 | - $mx = ''; | |
| 30 | - $mn = ''; | |
| 28 | + $mx = apply_filters('bitform_field_max_attr', '', $field); | |
| 29 | + $mn = apply_filters('bitform_field_min_attr', '', $field); | |
| 30 | + $minlength = $fieldHelpers->minlength(); | |
| 31 | + $maxlength = $fieldHelpers->maxlength(); | |
| 32 | + $maxword = $fieldHelpers->maxword(); | |
| 33 | + $minword = $fieldHelpers->minword(); | |
| 31 | 34 | $ph = $fieldHelpers->placeholder(); |
| 32 | 35 | $value = $fieldHelpers->value(); |
| 36 | + $ariaDescribedBy = $fieldHelpers->ariaDescribedBy(); | |
| 37 | + $ariaRequired = $fieldHelpers->ariaRequired(); | |
| 33 | 38 | $list = ''; |
| 34 | 39 | $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds; |
| 35 | 40 | $contentCount = count($bfFrontendFormIds); |
| 41 | + $sugg = apply_filters('bitform_field_suggestions_datalist', '', $field, $rowID, $contentCount); | |
| 36 | 42 | |
| 37 | - if (property_exists($field, 'suggestions') && count($field->suggestions) > 0) { | |
| 43 | + if (is_object($field) && property_exists($field, 'suggestions') && is_countable($field->suggestions) && count($field->suggestions) > 0) { | |
| 38 | 44 | $list = "list='{$rowID}-{$contentCount}-datalist'"; |
| 39 | - $sugg .= "<datalist id='{$rowID}-{$contentCount}-datalist'>"; | |
| 40 | - foreach ($field->suggestions as $suggestion) { | |
| 41 | - $val = (isset($suggestion->val) && !empty($suggestion->val)) ? $suggestion->val : $suggestion->lbl; | |
| 42 | - $sugg .= "<option value='{$fieldHelpers->esc_attr($val)}'>{$fieldHelpers->esc_html($suggestion->lbl)}</option>"; | |
| 43 | - } | |
| 44 | - $sugg .= '</datalist>'; | |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if (property_exists($field, 'mn') && '' !== $field->mn) { | |
| 48 | - $mn = "min='{$fieldHelpers->esc_attr($field->mn)}'"; | |
| 49 | - } | |
| 47 | + $inputWrapperCustomAttributes = $fieldHelpers->getCustomAttributes('inp-fld-wrp'); | |
| 48 | + $inputWrapperClass = $fieldHelpers->getConversationalCls('inp-fld-wrp') . ' ' . $fieldHelpers->getCustomClasses('inp-fld-wrp'); | |
| 49 | + $fieldCustomAttributes = $fieldHelpers->getCustomAttributes('fld'); | |
| 50 | + $fieldClass = $fieldHelpers->getConversationalCls('focus-elm') . ' ' . $fieldHelpers->getConversationalMultiCls('fld') . ' ' . $fieldHelpers->getCustomClasses('fld'); | |
| 51 | + $id = "{$rowID}-{$contentCount}"; | |
| 50 | 52 | |
| 51 | - if (property_exists($field, 'mx') && '' !== $field->mx) { | |
| 52 | - $mx = "max='{$fieldHelpers->esc_attr($field->mx)}'"; | |
| 53 | - } | |
| 54 | - | |
| 55 | - if (property_exists($field, 'inputMode') && '' !== $field->inputMode) { | |
| 56 | - $inputMode = "inputMode='{$fieldHelpers->esc_attr($field->inputMode)}'"; | |
| 57 | - } | |
| 58 | - | |
| 59 | - return <<<TEXTFIELD | |
| 60 | - <div | |
| 61 | - {$fieldHelpers->getCustomAttributes('inp-fld-wrp')} | |
| 62 | - class="{$fieldHelpers->getConversationalCls('inp-fld-wrp')} {$fieldHelpers->getCustomClasses('inp-fld-wrp')}" | |
| 53 | + return '<div | |
| 54 | + ' . $inputWrapperCustomAttributes . ' | |
| 55 | + class="' . $inputWrapperClass . '" | |
| 63 | 56 | > |
| 64 | 57 | <input |
| 65 | - {$fieldHelpers->getCustomAttributes('fld')} | |
| 66 | - id="{$rowID}-{$contentCount}" | |
| 67 | - {$list} | |
| 68 | - class="{$fieldHelpers->getConversationalCls('focus-elm')} {$fieldHelpers->getConversationalMultiCls('fld')} {$fieldHelpers->getCustomClasses('fld')}" | |
| 69 | - type="{$field->typ}" | |
| 70 | - {$req} | |
| 71 | - {$disabled} | |
| 72 | - {$readonly} | |
| 73 | - {$ph} | |
| 74 | - {$mn} | |
| 75 | - {$mx} | |
| 76 | - {$ac} | |
| 77 | - {$inputMode} | |
| 78 | - {$name} | |
| 79 | - {$value} | |
| 58 | + ' . $fieldCustomAttributes . ' | |
| 59 | + id="' . $id . '" | |
| 60 | + ' . $list . ' | |
| 61 | + class="' . $fieldClass . '" | |
| 62 | + type="' . $field->typ . '" | |
| 63 | + ' . $req . ' | |
| 64 | + ' . $ariaRequired . ' | |
| 65 | + ' . $ariaDescribedBy . ' | |
| 66 | + ' . $disabled . ' | |
| 67 | + ' . $readonly . ' | |
| 68 | + ' . $ph . ' | |
| 69 | + ' . $mn . ' | |
| 70 | + ' . $mx . ' | |
| 71 | + ' . $minlength . ' | |
| 72 | + ' . $maxlength . ' | |
| 73 | + ' . $maxword . ' | |
| 74 | + ' . $minword . ' | |
| 75 | + ' . $ac . ' | |
| 76 | + ' . $inputMode . ' | |
| 77 | + ' . $name . ' | |
| 78 | + ' . $value . ' | |
| 80 | 79 | /> |
| 81 | - {$prefixIcn} | |
| 82 | - {$suffixIcn} | |
| 80 | + ' . $prefixIcn . ' | |
| 81 | + ' . $suffixIcn . ' | |
| 83 | 82 | </div> |
| 84 | - {$sugg} | |
| 85 | -TEXTFIELD; | |
| 83 | + ' . $sugg; | |
| 86 | 84 | } |
| 87 | 85 | } |