Files
formy/app/forms.R

39 lines
756 B
R

options(box.path = here::here())
box::use(
modules/utils,
)
#' @export
load_data_to_form <- function(
df,
table_name = "main",
mhcs,
ns
) {
input_types <- unname(mhcs()$get_id_type_list(table_name))
input_ids <- names(mhcs()$get_id_type_list(table_name))
if (missing(ns)) ns <- NULL
# transform df to list
# loaded_df_for_id <- as.list(df)
# loaded_df_for_id <- df[input_ids]
# rewrite input forms
purrr::walk2(
.x = input_types,
.y = input_ids,
.f = \(x_type, x_id) {
# updating forms with loaded data
utils$update_forms_with_data(
form_id = x_id,
form_type = x_type,
value = df[[x_id]],
scheme = mhcs()$get_scheme(table_name),
ns = ns
)
}
)
}