From 47ef59f15ec14cac644d8b6cd84ab0a219fb045f Mon Sep 17 00:00:00 2001 From: Luke Boelling Date: Fri, 18 Aug 2023 09:41:49 +0200 Subject: [PATCH] Adding Support for |-based splitting of labels See https://manual.limesurvey.org/Question_type_-_Array#General_description for the underlying approach --- R/input_radioMatrixInput.R | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/R/input_radioMatrixInput.R b/R/input_radioMatrixInput.R index af64b6c..62cd4fb 100644 --- a/R/input_radioMatrixInput.R +++ b/R/input_radioMatrixInput.R @@ -73,19 +73,42 @@ radioMatHeader <- function(.choices, .required) { #' radioBody <- function(.responseItems, .choices, .selected = NULL) { + + shiny::tags$tbody( lapply( X = .responseItems, function(item, choice, select) { + itembu <- item + item <- strsplit(item,split = "|",fixed = T)[[1]] + + if(length(item)==1){ shiny::tags$tr(class = "radio-matrix-buttons", - id = paste0("tr-", create_radio_input_id(item)), + id = paste0("tr-", create_radio_input_id(itembu)), shiny::tags$td(class = "radio-matrix-buttons-label", - id = paste0("td-", create_radio_input_id(item)), + id = paste0("td-", create_radio_input_id(itembu)), item ), - radioMatrixButtons(inputId = create_radio_input_id(item), + radioMatrixButtons(inputId = create_radio_input_id(itembu), choices = choice, selected = select) - ) + )} else { + + shiny::tags$tr(class = "radio-matrix-buttons", + id = paste0("tr-", create_radio_input_id(itembu)), + shiny::tags$td(class = "radio-matrix-buttons-label", + id = paste0("td-", create_radio_input_id(itembu)), + item[1] + ), + radioMatrixButtons(inputId = create_radio_input_id(itembu), + choices = choice, + selected = select), + shiny::tags$td(class = "radio-matrix-buttons-label", + id = paste0("td-", create_radio_input_id(itembu)), + item[2] + ) + ) + + } }, choice = .choices, select = .selected