";
$id = esc_attr($id);
$label = fluentform_sanitize_html($option['label']);
$ariaLabel = esc_attr($label);
// Here we can push the visual items
if ($hasImageOption) {
$elMarkup .= "
";
}
$ariaRequired = 'false';
if (ArrayHelper::get($data, 'settings.validation_rules.required.value')) {
$ariaRequired = 'true';
}
$disabled = ArrayHelper::get($option, 'disabled') ? 'disabled' : '';
$isOtherOption = ArrayHelper::get($option, 'is_other', false);
$otherClass = $isOtherOption ? ' ff-other-option' : '';
$elMarkup .= "
';
// Add text input for "Other" option
if ($isOtherOption && defined('FLUENTFORMPRO')) {
$otherPlaceholder = ArrayHelper::get($data, 'settings.other_option_placeholder', __('Please specify...', 'fluentform'));
$fieldName = str_replace(['[', ']'], '', $data['attributes']['name']);
$otherInputName = $fieldName . '__ff_other_input__';
$otherValue = '';
// Defaulted like the sibling reads above: forms saved before this
// setting existed would otherwise fall through to the field's
// "This field is required", which is wrong on an optional field.
$otherRequiredMessage = trim((string) ArrayHelper::get(
$data,
'settings.other_option_required_message',
__('Please specify a value for the selected "Other" option', 'fluentform')
));
// An "Other" that is already selected (configured or dynamic
// default) must render with its input visible and required —
// otherwise the field is mandatory but invisible and the form
// cannot be submitted at all.
$otherIsSelected = in_array($option['value'], $defaultValues);
$wrapperDisplay = $otherIsSelected ? '' : 'display: none; ';
$otherAriaRequired = $otherIsSelected ? " aria-required='true'" : '';
$marginTop = $hasImageOption ? '20px' : '8px';
$otherInputHtml .= "
";
// The id is what the validator points aria-describedby at when the
// free text is required but empty.
$otherInputId = $this->getUniqueid('ff_other_' . $fieldName);
$otherInputHtml .= "";
$otherInputHtml .= "
";
}
$elMarkup .= '
';
}
if ($hasImageOption) {
$elMarkup .= '