Fix validation not working for media fields. Closes #1365.

pull/1379/head
Anh Tran 4 years ago
parent 89299ed2b9
commit 6e96084024

3
.gitignore vendored

@ -1,3 +1,4 @@
.svn
node_modules
package-lock.json
package-lock.json
yarn.lock

@ -1,7 +1,7 @@
const { src, dest, series } = require('gulp');
const babel = require('gulp-babel');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify-es').default;
const terser = require('gulp-terser');
const clean = require('gulp-clean');
const validationCompile = () => {
@ -15,7 +15,7 @@ const validationCompile = () => {
const validationConcat = () => {
return src(['js/validation/jquery.validate.js', 'js/validation/additional-methods.js', 'js/build/validation.js'])
.pipe(concat('validation.min.js'))
.pipe(uglify())
.pipe(terser())
.pipe(dest('js'));
}

@ -145,11 +145,12 @@ class RWMB_Media_Field extends RWMB_File_Field {
public static function get_attributes( $field, $value = null ) {
$value = (array) $value;
$attributes = parent::get_attributes( $field, $value );
$attributes['type'] = 'hidden';
$attributes['name'] = $field['clone'] ? str_replace( '[]', '', $attributes['name'] ) : $attributes['name'];
$attributes['id'] = false;
$attributes['value'] = implode( ',', $value );
$attributes = parent::get_attributes( $field, $value );
$attributes['type'] = 'hidden';
$attributes['name'] = $field['clone'] ? str_replace( '[]', '', $attributes['name'] ) : $attributes['name'];
$attributes['id'] = false;
$attributes['value'] = implode( ',', $value );
$attributes['class'] .= ' rwmb-media';
// Add attachment details.
$attachments = array();

File diff suppressed because one or more lines are too long

@ -40,7 +40,7 @@
getSettings() {
this.settings = {
ignore: ':not([class|="rwmb"]:visible)',
ignore: ':not(.rwmb-media,[class|="rwmb"]:visible)',
errorPlacement: function( error, element ) {
error.appendTo( element.closest( '.rwmb-input' ) );
},

@ -1,7 +1,4 @@
{
"scripts": {
"build:validation": "babel js/validation.js --out-file js/validation.min.js --presets=@babel/preset-env,babel-preset-minify"
},
"devDependencies": {
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
@ -9,6 +6,6 @@
"gulp-babel": "^8.0.0",
"gulp-clean": "^0.4.0",
"gulp-concat": "^2.6.1",
"gulp-uglify-es": "^2.0.0"
"gulp-terser": "^1.2.0"
}
}

Loading…
Cancel
Save