Closed sjregan closed 2 years ago
In the future, please use the issue tracker here: (https://github.com/reduxframework/redux-framework). This beta repo is closed. I'll ask to have it taken down.
Change your validation function to this:
function validate_json( $field, $value, $existing_value ) {
$json = json_decode( $value );
if ( json_last_error() === JSON_ERROR_NONE ) {
$field['msg'] = '';
return array(
'value' => trim( $value ),
'error' => $field
);
}
$field['msg'] = esc_html__( 'You must enter valid JSON.', 'text-domain' );
return array(
'error' => $field,
'value' => trim( $existing_value ),
);
}
For custom validations, you'll have to pass a null or empty value to the field error and return it to make the message disappear on success.
This is a continuation of issue #196 .
Support Hash
https://support.redux.io/?id=yDWdaYTYRxDxPQglhZqGQ0HDgyezD78hUHJ0KylPK6nPQKD9GxbP%2FGGGkHSDxSCQ%2F8RAFZxGx5h8hWPZ2tr3ug%3D%3D
Steps to reproduce
Expected Behavior
The validation error message to be removed.
Actual Behavior
The validation error message remains on screen even though the field has passed validation and been saved.
Any Error Details (PHP/JavaScript)
Modifications to sample config:
Validation function: