Merge pull request #788 from ultimatemember/fix/checkbox_with_commas

Checkbox title with commas creating issue with default option
This commit is contained in:
Nikita Sinelnikov
2021-04-05 13:03:21 +03:00
committed by GitHub
+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 {