Fixed: default value with comma for checkbox

This commit is contained in:
yuriinalivaiko
2021-03-23 14:48:42 +02:00
parent 5fb10b8228
commit ce73840ce2
+8 -3
View File
@@ -1045,9 +1045,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
if ( ! $this->editing || 'custom' == $this->set_mode ) {
// show default on register screen if there is default
if ( isset( $data['default'] ) ) {
if ( ! is_array( $data['default'] ) && strstr( $data['default'], ', ' ) ) {
$data['default'] = explode( ', ', $data['default'] );
}
if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
return true;
@@ -1061,6 +1058,14 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
return true;
}
// default value with comma
if ( is_string( $data['default'] ) && strstr( $data['default'], ',' ) ) {
$choices = array_map( 'trim', explode( ',', $data['default'] ) );
if( in_array( $value, $choices ) ){
return true;
}
}
}
} else {