Skip to content

Commit dfad218

Browse files
committed
fix: formidable toggle options checks warnings
1 parent 642211c commit dfad218

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

forms-bridge/integrations/formidable/class-formidable-integration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ private function serialize_field( $field ) {
366366
$type = 'hidden';
367367
break;
368368
case 'toggle':
369-
if ( $field->options[0] === '' && $field->options[1] === '1' ) {
369+
if ( is_array( $field->options ) && '' === ( $field->options[0] ?? false ) && '1' === ( $field->options[1] ?? false ) ) {
370370
$type = 'checkbox';
371371
} else {
372372
$type = 'text';
@@ -531,7 +531,7 @@ private function field_value_schema( $field ) {
531531
case 'file':
532532
return null;
533533
case 'toggle':
534-
if ( $field->options[0] === '' && $field->options[1] === '1' ) {
534+
if ( is_array( $field->options ) && '' === ( $field->options[0] ?? false ) && '1' === ( $field->options[1] ?? false ) ) {
535535
$type = 'boolean';
536536
} else {
537537
$type = 'text';
@@ -665,7 +665,7 @@ private function format_value( $value, $field ) {
665665

666666
return $value;
667667
case 'toggle':
668-
return $field['type'] === 'checkbox' ? boolval( $value ) : $value;
668+
return 'checkbox' === $field['type'] ? boolval( $value ) : $value;
669669
default:
670670
return (string) $value;
671671
}

0 commit comments

Comments
 (0)