| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
$options = $component['options'] ?? array(); |
| 7 |
?> |
| 8 |
<div class="frm-text-toggle-component frm-radio-component <?php echo esc_attr( $component_class ); ?>"> |
| 9 |
<div class="frm-radio-container frm-flex-justify"> |
| 10 |
<?php |
| 11 |
$is_default_checked = isset( $component['default_value'] ) ? empty( $field_value ) && '' !== $component['default_value'] : empty( $field_value ); |
| 12 |
|
| 13 |
foreach ( $options as $index => $option ) { |
| 14 |
$input_attrs = array( |
| 15 |
'id' => 'frm-text-toggle-' . $field_name . '-' . $index, |
| 16 |
'value' => $option['value'] ?? '', |
| 17 |
); |
| 18 |
|
| 19 |
if ( empty( $component['input_attrs_str'] ) ) { |
| 20 |
$input_attrs['type'] = 'radio'; |
| 21 |
} |
| 22 |
?> |
| 23 |
<input |
| 24 |
<?php |
| 25 |
echo $component['input_attrs_str'] ?? $field_name; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 26 |
FrmAppHelper::array_to_html_params( $input_attrs, true ); |
| 27 |
checked( ( $is_default_checked && 0 === $index ) || $option['value'] == $field_value, true ); // phpcs:ignore Universal.Operators.StrictComparisons |
| 28 |
?> |
| 29 |
/> |
| 30 |
<label class="frm-force-flex-center <?php echo esc_attr( $option['classes'] ?? '' ); ?>" for="<?php echo esc_attr( $input_attrs['id'] ); ?>" tabindex="0" data-value="<?php echo esc_attr( $input_attrs['value'] ); ?>" <?php echo $option['custom_attrs'] ?? ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> |
| 31 |
<span class="frm-toggle-label"><?php echo esc_html( $option['label'] ?? '' ); ?></span> |
| 32 |
</label> |
| 33 |
<?php |
| 34 |
}//end foreach |
| 35 |
?> |
| 36 |
|
| 37 |
<span class="frm-radio-active-tracker"></span> |
| 38 |
</div> |
| 39 |
</div> |
| 40 |
|