{"action":"created","issue":{"url":"https://api.github.com/repos/rstudio/shiny/issues/1205","repository_url":"https://api.github.com/repos/rstudio/shiny","labels_url":"https://api.github.com/repos/rstudio/shiny/issues/1205/labels{/name}","comments_url":"https://api.github.com/repos/rstudio/shiny/issues/1205/comments","events_url":"https://api.github.com/repos/rstudio/shiny/issues/1205/events","html_url":"https://github.com/rstudio/shiny/issues/1205","id":158229550,"number":1205,"title":"Problems with Dynamic UI inside module","user":{"login":"carlganz","id":11653794,"avatar_url":"https://avatars.githubusercontent.com/u/11653794?v=3","gravatar_id":"","url":"https://api.github.com/users/carlganz","html_url":"https://github.com/carlganz","followers_url":"https://api.github.com/users/carlganz/followers","following_url":"https://api.github.com/users/carlganz/following{/other_user}","gists_url":"https://api.github.com/users/carlganz/gists{/gist_id}","starred_url":"https://api.github.com/users/carlganz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carlganz/subscriptions","organizations_url":"https://api.github.com/users/carlganz/orgs","repos_url":"https://api.github.com/users/carlganz/repos","events_url":"https://api.github.com/users/carlganz/events{/privacy}","received_events_url":"https://api.github.com/users/carlganz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-02T20:15:26Z","updated_at":"2016-06-03T07:11:38Z","closed_at":null,"body":"Hello,\r\n\r\nLet's say you have a module where you use `outputUI` to dynamically generate UI elements like so:\r\n\r\n```{R}\r\nsimpleModUI <- function(id) {\r\n  \r\n  ns <- NS(id)\r\n  sldr <- numericInput(ns(\"count\"),\"How many text boxes?\", 1,1,10)\r\n  ins <- uiOutput(ns(\"ins\"))\r\n  text <- verbatimTextOutput(ns(\"sentence\"))\r\n  tagList(\r\n    sldr,ins,text\r\n  )\r\n  \r\n}\r\n\r\nsimpleMod <- function(input, output, session) {\r\n  \r\n  output$ins <- renderUI({\r\n    lapply(seq_len(input$count),function(i) {\r\n      textInput(paste0(\"word_\",i),\"Enter a word here:\")\r\n    })\r\n  })\r\n  \r\n  output$sentence <- renderText({\r\n    x <- unlist(lapply(seq_len(input$count),function(i) {\r\n      # issue is probably here\r\n      val = input[[paste0(\"word_\",i)]]\r\n      if (is.null(val)) {\r\n        NA\r\n      } else {\r\n        val\r\n      }\r\n    }))\r\n    paste0(x,collapse=\", \")\r\n  })\r\n  \r\n}\r\n```\r\n\r\nThe UI dynamically generates correctly, but it doesn't seem like the values are accessible. It's not clear to me why `input$word_...` is null when I enter values into the textInput. Here is the code that calls the module:\r\n\r\n```{R}\r\nui <- fluidPage(\r\n  mainPanel(\r\n    simpleModUI(\"example\")\r\n  )\r\n)\r\n\r\nserver <- function(input, output, session) {\r\n  callModule(simpleMod,\"example\")\r\n}\r\n\r\nshinyApp(ui, server)\r\n```\r\n\r\nIs this a bug or am I misunderstanding how modules work?\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/rstudio/shiny/issues/comments/223507332","html_url":"https://github.com/rstudio/shiny/issues/1205#issuecomment-223507332","issue_url":"https://api.github.com/repos/rstudio/shiny/issues/1205","id":223507332,"user":{"login":"Vestaxis","id":6768797,"avatar_url":"https://avatars.githubusercontent.com/u/6768797?v=3","gravatar_id":"","url":"https://api.github.com/users/Vestaxis","html_url":"https://github.com/Vestaxis","followers_url":"https://api.github.com/users/Vestaxis/followers","following_url":"https://api.github.com/users/Vestaxis/following{/other_user}","gists_url":"https://api.github.com/users/Vestaxis/gists{/gist_id}","starred_url":"https://api.github.com/users/Vestaxis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vestaxis/subscriptions","organizations_url":"https://api.github.com/users/Vestaxis/orgs","repos_url":"https://api.github.com/users/Vestaxis/repos","events_url":"https://api.github.com/users/Vestaxis/events{/privacy}","received_events_url":"https://api.github.com/users/Vestaxis/received_events","type":"User","site_admin":false},"created_at":"2016-06-03T07:11:38Z","updated_at":"2016-06-03T07:11:38Z","body":"I guess Stackoverflow is a better place to ask these questions. \r\n\r\nYou should namespace your inputs that are generated server-side:\r\n\r\n```\r\nsimpleMod <- function(input, output, session) {\r\n  ns <- session$ns\r\n  \r\n  output$ins <- renderUI({\r\n    lapply(seq_len(input$count),function(i) {\r\n      textInput(ns(paste0(\"word_\",i)),\"Enter a word here:\")\r\n    })\r\n  })\r\n```"}}
{"actor":{"display_login":"Vestaxis"}}