I ran into an issue where an input
field is missing its name
attribute. I have been unable to set the value of this field with the set_values()
function, which specifically requires a name
to assign a value. Here is the function code:
function (form, ...)
{
new_values <- list(...)
no_match <- setdiff(names(new_values), names(form$fields))
if (length(no_match) > 0) {
stop("Unknown field names: ", paste(no_match, collapse = ", "),
call. = FALSE)
}
for (field in names(new_values)) {
type <- form$fields[[field]]$type %||% "non-input"
if (type == "hidden") {
warning("Setting value of hidden field '", field,
"'.", call. = FALSE)
}
else if (type == "submit") {
stop("Can't change value of submit input '", field,
"'.", call. = FALSE)
}
form$fields[[field]]$value <- new_values[[field]]
}
form
}
I would like to override set_values()
with a function that accepts either an input name, an id or other css selector.
Any ideas?