@@ -54,7 +54,10 @@ function determineType(field) {
5454 return "integer" ;
5555 } else if ( field . type === "boolean" ) {
5656 return "select-boolean" ;
57- } else if ( field . type === "string" || field . type . includes ( "string" ) ) {
57+ } else if ( field . type === "content" ) {
58+ return "content" ;
59+ }
60+ else if ( field . type === "string" || field . type . includes ( "string" ) ) {
5861 if ( field . format == "date-time" ) {
5962 return "datetime" ;
6063 }
@@ -65,6 +68,7 @@ function determineType(field) {
6568// Creates Form.io component based on json field type
6669function createComponent ( fieldName , fieldObject , requiredArray ) {
6770 const componentType = determineType ( fieldObject ) ;
71+ console . log ( componentType , "type determined" ) ;
6872 const validate = determineValidation ( fieldName , fieldObject , requiredArray ) ;
6973 switch ( componentType ) {
7074 case "textfield" :
@@ -239,6 +243,17 @@ function createComponent(fieldName, fieldObject, requiredArray) {
239243 components : [ ] ,
240244 validate
241245 } ;
246+ case "content" :
247+ return {
248+ html : `<p class="margin-top-neg-3 margin-bottom-4 text-base-dark">${ fieldObject [ "content" ] } </p>` ,
249+ label : fieldName ,
250+ customClass : fieldObject [ "className" ] ,
251+ refreshOnChange : false ,
252+ key : fieldName ,
253+ type : "content" ,
254+ input : false ,
255+ tableView : false
256+ } ;
242257 default :
243258 break ;
244259 }
@@ -282,6 +297,18 @@ function createAllComponents(schema, prefix = "") {
282297 }
283298
284299 components . push ( fieldComponent ) ;
300+
301+ // Add description below all object fields
302+ if ( fieldComponent . type === "datagrid" ) {
303+ const labelKey = `${ key } -description` ;
304+ const label = {
305+ type : "content" ,
306+ content : value . description ,
307+ className : ".margin-bottom-neg-205"
308+ }
309+ const labelComponent = createComponent ( labelKey , label , [ ] ) ;
310+ components . push ( labelComponent ) ;
311+ }
285312 }
286313 }
287314
0 commit comments