wrapper($input);
}
private static function field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
{
$fh = new ConversationalFieldHelpers($formID, $field, $rowID, $form_atomic_Cls_map);
$ph = isset($field->ph) ? $field->ph : '';
$val = !empty($value) ? $value : $fh->value();
$val = 'array' === gettype($val) ? ("value='" . implode(',', $val) . "'") : $val;
$name = $fh->name();
$req = $fh->required();
$ariaDescribedBy = $fh->ariaDescribedBy();
$ariaRequired = $fh->ariaRequired();
$readonlyCls = isset($field->valid->readonly) ? 'readonly' : '';
$disabledCls = isset($field->valid->disabled) ? 'disabled' : '';
$selectedOptImage = '';
$optionsList = '';
$activeList = isset($field->config->activeList) ? $field->config->activeList : null;
$optionIcon = '';
$allowCustomOption = isset($field->config->allowCustomOption) ? $field->config->allowCustomOption : false;
$img = htmlentities("data:image/svg+xml,");
if ($fh->property_exists_nested($field, 'config->optionIcon', true)) {
$optionIcon = sprintf(
'
',
$fh->getCustomAttributes('opt-icn'),
$fh->getCustomClasses('opt-icn'),
$img
);
}
if ($fh->property_exists_nested($field, 'config->selectedOptImage', true)) {
$selectedOptImage = sprintf(
'
',
$fh->getCustomAttributes('selected-opt-img'),
$fh->getConversationalMultiCls('selected-opt-img'),
$fh->getCustomClasses('selected-opt-img'),
$img
);
}
if (property_exists($field, 'optionsList')) {
foreach ($field->optionsList as $key => $value) {
$dataIndex = 0;
$valueArr = (array) $value;
$listName = array_keys($valueArr)[0];
$options = array_values($valueArr)[0];
$optionsList .= sprintf(
'
',
$fh->getCustomAttributes('option-list'),
$fh->getClassWithFieldKey('option-list'),
$fh->getConversationalCls('dpd-option-list'),
$fh->getCustomClasses('option-list'),
$fh->esc_attr($listName),
$key
);
if ($allowCustomOption) {
$optionsList .= sprintf(
'-
Create:
',
$fh->getCustomAttributes('option'),
$dataIndex,
$fh->getCustomClasses('option'),
$fh->getCustomAttributes('opt-lbl-wrp'),
$fh->getCustomClasses('opt-lbl-wrp'),
$fh->getCustomAttributes('opt-lbl'),
$fh->getCustomClasses('opt-lbl')
);
}
foreach ($options as $opt) {
if (isset($opt->type)) {
$disableOpt = isset($opt->disabled) ? 'disabled-opt' : '';
$optionsList .= sprintf(
'-
%7$s
',
$dataIndex,
$fh->getCustomAttributes('option'),
$fh->getCustomClasses('option'),
$disableOpt,
$fh->getCustomAttributes('opt-lbl'),
$fh->getCustomClasses('opt-lbl'),
$fh->kses_post($opt->title)
);
foreach ($opt->childs as $child) {
$optVal = isset($child->val) ? $child->val : $child->lbl;
$disableOpt = (isset($opt->disabled) || isset($child->disabled)) ? 'disabled-opt' : '';
$optImage = '';
if (isset($child->img)) {
$optImage = sprintf(
'
',
$fh->getCustomAttributes('opt-icn'),
$fh->getCustomClasses('opt-icn'),
$fh->esc_attr($child->lbl),
$fh->esc_url($child->img)
);
}
$optionsList .= sprintf(
' -
%8$s
%11$s
',
// 1: option attrs, 2: dataIndex, 3: optVal, 4: option class, 5: disableOpt,
// 6: opt-lbl-wrp attrs, 7: opt-lbl-wrp class, 8: optImage, 9: opt-lbl attrs, 10: opt-lbl class, 11: child label
$fh->getCustomAttributes('option'),
$dataIndex,
$fh->esc_attr($optVal),
$fh->getCustomClasses('option'),
$disableOpt,
$fh->getCustomAttributes('opt-lbl-wrp'),
$fh->getCustomClasses('opt-lbl-wrp'),
$optImage,
$fh->getCustomAttributes('opt-lbl'),
$fh->getCustomClasses('opt-lbl'),
$fh->kses_post($child->lbl)
);
}
} else {
$optVal = isset($opt->val) ? $opt->val : $opt->lbl;
$disableOpt = isset($opt->disabled) ? 'disabled-opt' : '';
$optImage = '';
if (isset($opt->img)) {
$optImage = sprintf(
'
',
$fh->getCustomAttributes('opt-icn'),
$fh->getCustomClasses('opt-icn'),
$fh->esc_attr($opt->lbl),
$fh->esc_url($opt->img)
);
}
$optionsList .= sprintf(
' -
%8$s
%11$s
',
// 1: option attrs, 2: dataIndex, 3: optVal, 4: option class, 5: disableOpt,
// 6: opt-lbl-wrp attrs, 7: opt-lbl-wrp class, 8: optImage, 9: opt-lbl attrs, 10: opt-lbl class, 11: opt label
$fh->getCustomAttributes('option'),
$dataIndex,
$fh->esc_attr($optVal),
$fh->getCustomClasses('option'),
$disableOpt,
$fh->getCustomAttributes('opt-lbl-wrp'),
$fh->getCustomClasses('opt-lbl-wrp'),
$optImage,
$fh->getCustomAttributes('opt-lbl'),
$fh->getCustomClasses('opt-lbl'),
$fh->kses_post($opt->lbl)
);
}
}
$optionsList .= '
';
$dataIndex++;
}
$optionsList .= sprintf(
'
',
$fh->getCustomAttributes('option-list'),
$fh->getClassWithFieldKey('option-list'),
$fh->getConversationalCls('dpd-option-list'),
$fh->getCustomClasses('option-list')
);
$multiChipClass = ($fh->property_exists_nested($field, 'config->multipleSelect', true) && $fh->property_exists_nested($field, 'config->showChip', true)) ? 'multi-chip' : '';
return '
getCustomAttributes('dpd-fld-wrp') . '
class="' . $fh->getClassWithFieldKey('dpd-fld-wrp') . ' ' . $fh->getConversationalCls('dpd-slct-fld-wrp') . ' ' . $fh->getCustomClasses('dpd-fld-wrp') . ' ' . $readonlyCls . ' ' . $disabledCls . '"
>
disabled() . '
' . $fh->readonly() . '
' . $val . '
/>
getCustomAttributes('dpd-wrp') . '
class="' . $fh->getClassWithFieldKey('dpd-wrp') . ' ' . $fh->getConversationalCls('dpd-slct-wrp') . ' ' . $fh->getCustomClasses('dpd-wrp') . '"
role="combobox"
aria-controls=""
aria-haspopup="listbox"
aria-live="assertive"
aria-expanded="false"
tabIndex="0"
aria-label="Dropdown"
>
getCustomAttributes('selected-opt-wrp') . '
class="' . $fh->getConversationalMultiCls('selected-opt-wrp') . ' ' . $fh->getCustomClasses('selected-opt-wrp') . '"
>
' . $selectedOptImage . '
getCustomAttributes('selected-opt-lbl') . '
aria-label="Selected Option Label"
class="' . $fh->getConversationalMultiCls('selected-opt-lbl') . ' ' . $multiChipClass . ' ' . $fh->getCustomClasses('selected-opt-lbl') . '"
>
' . $fh->esc_html($ph) . '
getCustomAttributes('dpd-btn-wrp') . '
class="' . $fh->getConversationalMultiCls('dpd-btn-wrp') . ' ' . $fh->getCustomClasses('dpd-btn-wrp') . '"
>
getCustomAttributes('dpd-down-btn') . '
class="' . $fh->getConversationalMultiCls('dpd-down-btn') . ' ' . $fh->getCustomClasses('dpd-down-btn') . '"
>
getCustomAttributes('option-wrp') . '
class="' . $fh->getConversationalMultiCls('option-wrp') . ' ' . $fh->getCustomClasses('option-wrp') . '"
>
getCustomAttributes('option-inner-wrp') . '
class="' . $fh->getConversationalMultiCls('option-inner-wrp') . ' ' . $fh->getCustomClasses('option-inner-wrp') . '"
>
getCustomAttributes('option-search-wrp') . '
class="' . $fh->getConversationalMultiCls('option-search-wrp') . ' ' . $fh->getCustomClasses('option-search-wrp') . '"
>
getCustomAttributes('opt-search-input') . '
type="search"
class="' . $fh->getConversationalMultiCls('opt-search-input') . ' ' . $fh->getCustomClasses('opt-search-input') . '"
placeholder="Search Country"
aria-label="Search Options"
aria-hidden="true"
tabIndex="-1"
/>
' . $optionsList . '
';
}
}
}