Learn R Programming

yonder (version 0.0.5)

formInput: Form inputs

Description

Form inputs are a new reactive input. Form inputs are an alternative to shiny's submit buttons. A form input is comprised of any number of inputs. The value of these inputs will not change until the form input's submit input is clicked. A form input's reactive value also depends on the submit input. This allows you to distinguish between different clicks if your form includes multiple submit inputs.

If id or submit are NULL the form input will not freeze its child inputs.

Usage

formInput(id, ..., submit = submitInput(), inline = FALSE)

Arguments

id

A character string specifying the id of the reactive input.

...

Any number of unnamed arguments (inputs or tag elements) passed as child elements of the form.

Additional named arguments passed as HTML attributes to the parent element.

submit

A submit button or tags containing a submit button. The submit button will trigger the update of input form elements. Defaults to submitInput().

inline

One of TRUE or FALSE, if TRUE the form and its child elements are rendered in a horizontal row, defaults to FALSE. On small viewports, think mobile device, inline has no effect and the form will span multiple lines.

Frozen inputs with scope

ui <- container(
  formInput(
    id = "form",
    formGroup(
      label = "Email",
      emailInput(
        id = "email"
      )
    ),
    formGroup(
      label = "Password",
      passwordInput(
        id = "password"
      )
    )
  )
)

server <- function(input, output) { }

shinyApp(ui, server)

Details

When inline is TRUE you may want to adjust the right margin of each child element for viewports larger than mobile, margin(<TAG>, right = c(sm = 2)), more information at margin(). You only need to apply extra space for larger viewports because inline forms do not take effect on small viewports.

See Also

Other inputs: buttonGroupInput, buttonInput, checkboxInput, chipInput, fileInput, groupInput, listGroupInput, menuInput, navInput, radioInput, rangeInput, selectInput, sliderInput, textInput

Examples

Run this code
# NOT RUN {
### Customizing the submit button

card(
  header = "Please pick a flavor",
  formInput(
    id = NULL,
    formGroup(
      label = "Ice creams",
      radioInput(
        id = "flavorChoice",
        choices = c("Mint", "Moose tracks", "Marble"),
      )
    ),
    submit = submitInput(  # <-
      label = "Make choice",
      block = TRUE
    ) %>%
      background("teal")
  )
) %>%
  border("teal") %>%
  width(50)

# }

Run the code above in your browser using DataLab