| 1 |
<?php |
| 2 |
|
| 3 |
namespace BitCode\BitForm\Frontend\Form\View\Conversational\Fields; |
| 4 |
|
| 5 |
use BitCode\BitForm\Core\Util\FrontendHelpers; |
| 6 |
|
| 7 |
class TextField |
| 8 |
{ |
| 9 |
public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null) |
| 10 |
{ |
| 11 |
$inputWrapper = new ConversationalInputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); |
| 12 |
$input = self::field($formID, $field, $rowID, $form_atomic_Cls_map, $value); |
| 13 |
return $inputWrapper->wrapper($input); |
| 14 |
} |
| 15 |
|
| 16 |
private static function field($formID, $field, $rowID, $form_atomic_Cls_map, $value) |
| 17 |
{ |
| 18 |
$fieldHelpers = new ConversationalFieldHelpers($formID, $field, $rowID, $form_atomic_Cls_map); |
| 19 |
|
| 20 |
$prefixIcn = $fieldHelpers->icon('prefixIcn', 'pre-i'); |
| 21 |
$suffixIcn = $fieldHelpers->icon('suffixIcn', 'suf-i'); |
| 22 |
$req = $fieldHelpers->required(); |
| 23 |
$disabled = $fieldHelpers->disabled(); |
| 24 |
$readonly = $fieldHelpers->readonly(); |
| 25 |
$inputMode = apply_filters('bitform_field_inputmode_attr', '', $field); |
| 26 |
$name = $fieldHelpers->name(); |
| 27 |
$ac = $fieldHelpers->autocomplete(); |
| 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(); |
| 34 |
$ph = $fieldHelpers->placeholder(); |
| 35 |
$value = $fieldHelpers->value(); |
| 36 |
$ariaDescribedBy = $fieldHelpers->ariaDescribedBy(); |
| 37 |
$ariaRequired = $fieldHelpers->ariaRequired(); |
| 38 |
$list = ''; |
| 39 |
$bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds; |
| 40 |
$contentCount = count($bfFrontendFormIds); |
| 41 |
$sugg = apply_filters('bitform_field_suggestions_datalist', '', $field, $rowID, $contentCount); |
| 42 |
|
| 43 |
if (is_object($field) && property_exists($field, 'suggestions') && is_countable($field->suggestions) && count($field->suggestions) > 0) { |
| 44 |
$list = "list='{$rowID}-{$contentCount}-datalist'"; |
| 45 |
} |
| 46 |
|
| 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}"; |
| 52 |
|
| 53 |
return '<div |
| 54 |
' . $inputWrapperCustomAttributes . ' |
| 55 |
class="' . $inputWrapperClass . '" |
| 56 |
> |
| 57 |
<input |
| 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 . ' |
| 79 |
/> |
| 80 |
' . $prefixIcn . ' |
| 81 |
' . $suffixIcn . ' |
| 82 |
</div> |
| 83 |
' . $sugg; |
| 84 |
} |
| 85 |
} |
| 86 |
|