wrapper($input); } private static function field($field, $rowID, $form_atomic_Cls_map, $formID, $value) { $fieldHelpers = new ConversationalFieldHelpers($formID, $field, $rowID, $form_atomic_Cls_map); $name = $fieldHelpers->name(); $req = $fieldHelpers->required(); $ariaDescribedBy = $fieldHelpers->ariaDescribedBy(); $ariaRequired = $fieldHelpers->ariaRequired(); $labelId = $fieldHelpers->getLabelId(); $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds; $contentCount = count($bfFrontendFormIds); $ratingOption = ''; $checkedIndex = ''; if (isset($field->opt)) { $defaultValue = isset($field->val) ? $field->val : ''; foreach ($field->opt as $key => $opt) { if ($defaultValue && $defaultValue === $opt->val) { $checkedIndex = $key; } elseif (isset($opt->check) && true === $opt->check) { $checkedIndex = $key; } } $checkedCls = null; foreach ($field->opt as $key => $opt) { $val = $opt->val; $img = $opt->img; $lbl = $opt->lbl; $checked = ''; // if ($defaultValue && $opt->val === $defaultValue) { // $checked = "checked='checked'"; // } elseif (isset($opt->check) && true === $opt->check) { // $checked = "checked='{$opt->check}'"; // } else { // $checked = ''; // } if ($defaultValue) { if ($opt->val === $defaultValue) { $checked = "checked='1'"; } } else { if (isset($opt->check) && true === $opt->check) { $checked = "checked='{$opt->check}'"; } else { $checked = ''; } } if (!empty($checkedIndex) && $key <= $checkedIndex) { $checkedCls = $rowID . '-rating-selected'; } else { $checkedCls = null; } // sprintf args order: // 1: label class, 2: rowID, 3: contentCount, 4: key, 5: label attrs // 6: input class, 7: name attr, 8: value, 9: label text, 10: checked, 11: required, 12: input attrs // 13: img class, 14: img src, 15: img attrs $ratingOption .= sprintf( ' ', $fieldHelpers->getConversationalMultiCls('rating-lbl') . ' ' . $fieldHelpers->getCustomClasses('rating-lbl'), $rowID, $contentCount, $key, $fieldHelpers->getCustomAttributes('rating-lbl'), $fieldHelpers->getConversationalMultiCls('rating-input') . ' ' . $fieldHelpers->getCustomClasses('rating-input'), $name, $val, $lbl, $checked, $req, $fieldHelpers->getCustomAttributes('rating-input'), $fieldHelpers->getConversationalMultiCls('rating-img') . ' ' . $fieldHelpers->getCustomClasses('rating-img') . ' ' . $checkedCls, $img, $fieldHelpers->getCustomAttributes('rating-img') ); } } return sprintf( '