File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
admin/form-builder/assets/js Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 122122 state . form_fields [ i ] [ 'read_only' ] = false ;
123123 }
124124
125- if ( payload . field_name === 'name' && ! state . form_fields [ i ] . hasOwnProperty ( 'is_new' ) ) {
125+ let meta_exist = state . form_fields . filter ( function ( field ) {
126+ return 'yes' === field . is_meta && field . name === payload . value ;
127+ } ) ;
128+
129+ if ( meta_exist . length ) {
130+ swal ( {
131+ text : 'Duplicate Meta Key' ,
132+ type : 'warning' ,
133+ confirmButtonColor : '#d54e21' ,
134+ confirmButtonText : 'Enter another key' ,
135+ confirmButtonClass : 'btn btn-success' ,
136+ } ) ;
137+ }
138+
139+ if ( ( payload . field_name === 'name' && payload . value . length - 2 < payload . field_name . length ) || ! state . form_fields [ i ] . hasOwnProperty ( 'is_new' ) ) {
126140 continue ;
127141 } else {
128142 state . form_fields [ i ] [ payload . field_name ] = payload . value ;
Original file line number Diff line number Diff line change 122122 state . form_fields [ i ] [ 'read_only' ] = false ;
123123 }
124124
125- if ( payload . field_name === 'name' && ! state . form_fields [ i ] . hasOwnProperty ( 'is_new' ) ) {
125+ let meta_exist = state . form_fields . filter ( function ( field ) {
126+ return 'yes' === field . is_meta && field . name === payload . value ;
127+ } ) ;
128+
129+ if ( meta_exist . length ) {
130+ swal ( {
131+ text : 'Duplicate Meta Key' ,
132+ type : 'warning' ,
133+ confirmButtonColor : '#d54e21' ,
134+ confirmButtonText : 'Enter another key' ,
135+ confirmButtonClass : 'btn btn-success' ,
136+ } ) ;
137+ }
138+
139+ if ( ( payload . field_name === 'name' && payload . value . length - 2 < payload . field_name . length ) || ! state . form_fields [ i ] . hasOwnProperty ( 'is_new' ) ) {
126140 continue ;
127141 } else {
128142 state . form_fields [ i ] [ payload . field_name ] = payload . value ;
You can’t perform that action at this time.
0 commit comments