Skip to content

Commit

Permalink
Add support for D.T boolean fields
Browse files Browse the repository at this point in the history
  • Loading branch information
corsacca committed Mar 28, 2024
1 parent dbc7835 commit ad4f049
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions includes/create-contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ public function create_contact_record( $params ) {
}
}
break;
case 'boolean':
$fields[$field['dt_field']] = $lead_value === 'on';
$notes[$lead_key] = ( $field['labels'] ?? $field['dt_field'] ) . ': ' . ( $lead_value === 'on' ? 'Yes' : 'No' );
break;

default:
continue 2;
break;
Expand Down
3 changes: 2 additions & 1 deletion includes/post-type-active-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public function load_extra_fields_meta_box( $post ) {
case 'date':
case 'communication_channel':
case 'text':
case 'boolean':
$this->template_row_dt_field_single( $unique_key, $data );
break;
case 'location':
Expand Down Expand Up @@ -504,7 +505,7 @@ function add_dt_fields( id ) {
vInput.append(`<input name="field_${unique_key}[values][]" value="${i}" />`)
})
}
if ( 'text' === v.type || 'communication_channel' === v.type || 'date' === v.type ) {
if ( 'text' === v.type || 'communication_channel' === v.type || 'date' === v.type || 'boolean' === v.type ) {
labels.append(`<input name="field_${unique_key}[labels]" id="new-labels-${unique_key}" value="${v.name}" />`)
}
}
Expand Down
16 changes: 16 additions & 0 deletions includes/utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,22 @@ function clear_timer() {
}

break;
case 'boolean':
// text box
?>
<div id="section-<?php echo esc_attr( $dt_webform_value['key'] ) ?>"
class="section single-checkbox section-<?php echo esc_attr( $dt_webform_value['type'] ) ?>">
<input type="checkbox"
id="<?php echo esc_attr( $dt_webform_value['key'] ) ?>"
name="<?php echo esc_attr( $dt_webform_value['key'] ) ?>"
class="input-<?php echo esc_attr( $dt_webform_value['type'] ) ?>"
<?php echo esc_attr( $dt_webform_value['required'] == 'yes' ? 'required' : '' ) ?>
/>
<label for="<?php echo esc_attr( $dt_webform_value['key'] ) ?>"
class="label-<?php echo esc_attr( $dt_webform_value['type'] ) ?> label-<?php echo esc_attr( $dt_webform_value['key'] ) ?>"><?php echo esc_html( $dt_webform_value['labels'] ) ?></label>
</div>
<?php
break;

default:
break;
Expand Down

0 comments on commit ad4f049

Please sign in to comment.