Skip to content

Commit f651e06

Browse files
committed
initialize validation state for pods editor #6898
1 parent b44d327 commit f651e06

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

ui/js/dfv/src/pods-dfv.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -811,25 +811,32 @@ window.PodsDFV = {
811811
// Create stores for each of the individual keys we found (the keys of
812812
// the initialStoresWithValues object).
813813
const initialStoreKeys = Object.keys( initialStoresWithValues );
814+
814815
const storeKeys = initialStoreKeys.map( ( storeKey ) => {
816+
//Validation state
817+
const validation = {
818+
validationMessages: Object.keys( initialStoresWithValues[ storeKey ] ).reduce( ( acc, key ) => {
819+
acc[ key ] = [];
820+
return acc;
821+
}, {} ),
822+
needsValidation: false,
823+
};
815824
// The Edit Pod screen gets a different store set up than
816825
// other contexts.
817826
if ( isEditPodScreen() ) {
818827
return initEditPodStore(
819-
window.podsAdminConfig,
828+
{
829+
...window.podsAdminConfig,
830+
...validation,
831+
},
820832
storeKey
821833
);
822834
} else if ( window.podsDFVConfig ) {
823-
const validationMessages = Object.keys( initialStoresWithValues[ storeKey ] ).reduce( ( acc, key ) => {
824-
acc[ key ] = [];
825-
return acc;
826-
}, {} );
827835
return initPodStore(
828836
window.podsDFVConfig,
829837
{
830838
...initialStoresWithValues[ storeKey ],
831-
validationMessages,
832-
needsValidation: false,
839+
...validation,
833840
},
834841
storeKey,
835842
);

ui/js/dfv/src/store/store.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const initEditPodStore = ( config, storeKey = '' ) => {
8484
},
8585
...omit( config, [ 'fieldTypes', 'relatedObjects' ] ),
8686
};
87-
87+
console.log({initEditPodStore:initialState});
8888
return initStore( initialState, storeKey );
8989
};
9090

@@ -97,6 +97,7 @@ export const initPodStore = ( config = {}, initialValues = {}, storeKey = '' ) =
9797
...omit( config, [ 'fieldTypes', 'relatedObjects' ] ),
9898
currentPod: initialValues,
9999
};
100+
console.log({initPodStore:initialState});
100101

101102
return initStore( initialState, storeKey );
102103
};

0 commit comments

Comments
 (0)