| 1 |
<?php |
| 2 |
/** |
| 3 |
* Sub field options |
| 4 |
* |
| 5 |
* @package Formidable |
| 6 |
* @since 4.10.02 |
| 7 |
* |
| 8 |
* @var FrmFieldCombo $this Field type object. |
| 9 |
* @var array $field Field array. |
| 10 |
* @var array $sub_field Sub field array. |
| 11 |
* @var array $default_value Default value of all sub fields. |
| 12 |
* @var array $wrapper_classes CSS classes of wrapper element of subfield options. |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
die( 'You are not allowed to call this page directly.' ); |
| 17 |
} |
| 18 |
|
| 19 |
$field_id = $field['id']; |
| 20 |
$field_key = $field['field_key']; |
| 21 |
$uniq_str = $sub_field['name'] . '_' . $field_id; |
| 22 |
$labels = $this->get_built_in_option_labels(); |
| 23 |
?> |
| 24 |
<div |
| 25 |
class="<?php echo esc_attr( $wrapper_classes ); ?>" |
| 26 |
data-sub-field-name="<?php echo esc_attr( $sub_field['name'] ); ?>" |
| 27 |
data-field-id="<?php echo intval( $field_id ); ?>" |
| 28 |
> |
| 29 |
<label id="<?php echo esc_attr( $uniq_str ); ?>" class="frm_primary_label"> |
| 30 |
<?php echo esc_html( $sub_field['label'] ); ?> |
| 31 |
</label> |
| 32 |
|
| 33 |
<?php |
| 34 |
// Loop through $sub_field['options'] to show options. |
| 35 |
foreach ( $sub_field['options'] as $option ) { |
| 36 |
switch ( $option ) { |
| 37 |
case 'default_value': |
| 38 |
$input_name = sprintf( '%1$s_%2$s[%3$s]', $option, $field_id, $sub_field['name'] ); |
| 39 |
$input_id = $option . '_' . $uniq_str; |
| 40 |
?> |
| 41 |
<p class="frm6 frm_form_field"> |
| 42 |
<span class="frm-with-right-icon"> |
| 43 |
<?php |
| 44 |
FrmAppHelper::icon_by_class( |
| 45 |
'frm_icon_font frm_more_horiz_solid_icon frm-show-inline-modal', |
| 46 |
array( |
| 47 |
'data-open' => 'frm-smart-values-box', |
| 48 |
) |
| 49 |
); |
| 50 |
?> |
| 51 |
<input |
| 52 |
type="text" |
| 53 |
name="<?php echo esc_attr( $input_name ); ?>" |
| 54 |
id="<?php echo esc_attr( $input_id ); ?>" |
| 55 |
value="<?php echo esc_attr( isset( $default_value[ $sub_field['name'] ] ) ? $default_value[ $sub_field['name'] ] : '' ); ?>" |
| 56 |
data-changeme="field_<?php echo esc_attr( $field_key . '_' . $sub_field['name'] ); ?>" |
| 57 |
data-changeatt="value" |
| 58 |
/> |
| 59 |
</span> |
| 60 |
<label class="frm_description" for="<?php echo esc_attr( $input_id ); ?>"> |
| 61 |
<?php echo esc_html( $labels[ $option ] ); ?> |
| 62 |
</label> |
| 63 |
</p> |
| 64 |
<?php |
| 65 |
break; |
| 66 |
|
| 67 |
// All simple text options with live update the form output can go here. |
| 68 |
case 'placeholder': |
| 69 |
$input_name = sprintf( 'field_options[%1$s_%2$s][%3$s]', $option, $field_id, $sub_field['name'] ); |
| 70 |
$input_id = 'field_options_' . $option . '_' . $uniq_str; |
| 71 |
$input_value = FrmField::get_option( $field, $option ); |
| 72 |
?> |
| 73 |
<p class="frm6 frm_form_field"> |
| 74 |
<input |
| 75 |
type="text" |
| 76 |
name="<?php echo esc_attr( $input_name ); ?>" |
| 77 |
id="<?php echo esc_attr( $input_id ); ?>" |
| 78 |
value="<?php echo esc_attr( isset( $input_value[ $sub_field['name'] ] ) ? $input_value[ $sub_field['name'] ] : '' ); ?>" |
| 79 |
data-changeme="field_<?php echo esc_attr( $field_key . '_' . $sub_field['name'] ); ?>" |
| 80 |
data-changeatt="<?php echo esc_attr( $option ); ?>" |
| 81 |
/> |
| 82 |
<label class="frm_description" for="<?php echo esc_attr( $input_id ); ?>"> |
| 83 |
<?php echo esc_html( $labels[ $option ] ); ?> |
| 84 |
</label> |
| 85 |
</p> |
| 86 |
<?php |
| 87 |
break; |
| 88 |
|
| 89 |
// All simple text options without live update the form output can go here. |
| 90 |
case 'desc': |
| 91 |
$input_name = sprintf( 'field_options[%1$s_%2$s_%3$s]', $sub_field['name'], $option, $field_id ); |
| 92 |
$input_id = 'field_options_' . $option . '_' . $uniq_str; |
| 93 |
$input_value = FrmField::get_option( $field, $sub_field['name'] . '_' . $option ); |
| 94 |
?> |
| 95 |
<p class="frm6 frm_form_field"> |
| 96 |
<input |
| 97 |
type="text" |
| 98 |
name="<?php echo esc_attr( $input_name ); ?>" |
| 99 |
id="<?php echo esc_attr( $input_id ); ?>" |
| 100 |
value="<?php echo esc_attr( $input_value ); ?>" |
| 101 |
data-changeme="frm_field_<?php echo esc_attr( $field_id . '_' . $sub_field['name'] ); ?>_desc" |
| 102 |
/> |
| 103 |
<label class="frm_description" for="<?php echo esc_attr( $input_id ); ?>"> |
| 104 |
<?php echo esc_html( $labels[ $option ] ); ?> |
| 105 |
</label> |
| 106 |
</p> |
| 107 |
<?php |
| 108 |
break; |
| 109 |
} |
| 110 |
} |
| 111 |
?> |
| 112 |
<div class="frm12"></div> |
| 113 |
</div><!-- End .frm_sub_field_options --> |
| 114 |
|