Closed Ryo-N7 closed 1 year ago
So the branch for v4.33 has formSchemaFromData(x, databaseId, label, folderId = databaseId, keyColumns = character(), logicalAsSingleSelect = TRUE, logicalText = c("True","False"))
which will build a formSchema from a data.frame.
formSchemaFromData(x = tibble(a = 1:5, b = factor(paste0(1:5, "_stuff")), a_logical_column = 1:5==4, date_col = (seq(as.Date("2021-07-06"),as.Date("2021-07-10"),by = 1))), databaseId = "Some database", label = "My new form schema!!", keyColumns = "b", logicalAsSingleSelect = FALSE)
I have left more to the user in terms of dealing with dates but it will create a formSchema with a date form field if there is a date column. A date-time column is converted to a character column for now since I didn't find an equivalent type and it would be up to the user to split it into two columns with date and time if necessary.
Would it could be useful to have a way to select existing columns from existing forms to duplicate into a new schema? This might be a more natural way of dealing with data that may have sub-forms and reference fields and/or multiple select.
Would it could be useful to have a way to select existing columns from existing forms to duplicate into a new schema? This might be a more natural way of dealing with data that may have sub-forms and reference fields and/or multiple select.
yeah i think this would be nice, because there are times we may want to create sub-forms or similar form-subform relationships more than once
based off of the work done in #44 #32 >> next step would be to let users have a data.frame, imported CSV/Excel file in R be transformed into an activityinfo form by using the various form schema helper functions
the difficult part would be stuff like single-select/multiple select since those would all be simple 'text' fields in a data.frame when checked with
str()
ordplyr::glimpse()
. so i imagine for special fields, the user would need to specify certain columns/fields in their data.frame to be a certain field type so that the constructor function will handle it properly when creating the form schema based off the data.frame