@@ -155,23 +155,33 @@ export const ObjectForm: React.FC<ObjectFormProps> = ({
155155 // Determine which fields to include
156156 const fieldsToShow = schema . fields || Object . keys ( objectSchema . fields || { } ) ;
157157
158- fieldsToShow . forEach ( ( fieldName ) => {
159- const field = objectSchema . fields ?. [ fieldName ] ;
160- if ( ! field ) return ;
158+ // Support object format for fields in schema (legacy/compat)
159+ const fieldNames = Array . isArray ( fieldsToShow )
160+ ? fieldsToShow
161+ : Object . keys ( fieldsToShow ) ;
162+
163+ fieldNames . forEach ( ( fieldName ) => {
164+ // If fieldsToShow is an array of strings, fieldName is the string
165+ // If fieldsToShow is array of objects (unlikely but possible in some formats), we need to extract name
166+ const name = typeof fieldName === 'string' ? fieldName : ( fieldName as any ) . name ;
167+ if ( ! name ) return ;
168+
169+ const field = objectSchema . fields ?. [ name ] ;
170+ if ( ! field && ! hasInlineFields ) return ; // Skip if not found in object definition unless inline
161171
162172 // Check field-level permissions for create/edit modes
163- const hasWritePermission = ! field . permissions || field . permissions . write !== false ;
173+ const hasWritePermission = ! field ? .permissions || field ? .permissions . write !== false ;
164174 if ( schema . mode !== 'view' && ! hasWritePermission ) return ; // Skip fields without write permission
165175
166176 // Check if there's a custom field configuration
167- const customField = schema . customFields ?. find ( f => f . name === fieldName ) ;
177+ const customField = schema . customFields ?. find ( f => f . name === name ) ;
168178
169179 if ( customField ) {
170180 generatedFields . push ( customField ) ;
171- } else {
181+ } else if ( field ) {
172182 // Auto-generate field from schema
173183 const formField : FormField = {
174- name : fieldName ,
184+ name : name ,
175185 label : field . label || fieldName ,
176186 type : mapFieldTypeToFormType ( field . type ) ,
177187 required : field . required || false ,
0 commit comments