File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -253,13 +253,13 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
253253 resource : AdminForthResource ; record : any ; adminUser : any ;
254254 } ) : Promise < { error ?: string ; ok : boolean ; createdRecord ?: any ; } > {
255255 // transform value using setFieldValue and call createRecordOriginalValues
256-
256+
257257 const filledRecord = { ...record } ;
258258 const recordWithOriginalValues = { ...record } ;
259259
260260 for ( const col of resource . dataSourceColumns ) {
261261 if ( col . fillOnCreate ) {
262- if ( filledRecord [ col . name ] === undefined ) {
262+ if ( filledRecord [ col . name ] === undefined || ( Array . isArray ( filledRecord [ col . name ] ) && filledRecord [ col . name ] . length === 0 ) ) {
263263 filledRecord [ col . name ] = col . fillOnCreate ( {
264264 initialRecord : record ,
265265 adminUser
Original file line number Diff line number Diff line change @@ -64,6 +64,11 @@ async function isShown(
6464 return true ;
6565}
6666
67+ async function isFilledOnCreate ( col : AdminForthResource [ 'columns' ] [ number ] ) : Promise < boolean > {
68+ const fillOnCreate = ! ! col . fillOnCreate ;
69+ return fillOnCreate ;
70+ }
71+
6772export async function interpretResource (
6873 adminUser : AdminUser ,
6974 resource : AdminForthResource ,
@@ -1190,9 +1195,10 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
11901195 for ( const column of resource . columns ) {
11911196 const fieldName = column . name ;
11921197 if ( fieldName in record ) {
1193- const shown = await isShown ( column , 'create' , ctxCreate ) ;
1198+ const shown = await isShown ( column , 'create' , ctxCreate ) ; //
11941199 const bo = await isBackendOnly ( column , ctxCreate ) ;
1195- if ( ! shown || bo ) {
1200+ const filledOnCreate = await isFilledOnCreate ( column ) ;
1201+ if ( ( ! shown && ! filledOnCreate ) || bo ) {
11961202 return { error : `Field "${ fieldName } " cannot be modified as it is restricted from creation (backendOnly or showIn.create is false, please set it to true)` , ok : false } ;
11971203 }
11981204 }
You can’t perform that action at this time.
0 commit comments