Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_values cannot modify input checkboxes #127

Closed
dbuijs opened this issue Dec 18, 2015 · 2 comments
Closed

set_values cannot modify input checkboxes #127

dbuijs opened this issue Dec 18, 2015 · 2 comments
Labels
feature a feature request or enhancement form 🧾

Comments

@dbuijs
Copy link

dbuijs commented Dec 18, 2015

In looking at the code for the set_values function, it doesn't seem to be able to handle changing the checked attribute of input checkboxes. It also doesn't throw any errors if you try to change the value of an input checkbox.

Short-term, an error message in the set_values function would be helpful if you try to change the value of a checkbox.

Medium-term, a method to change the checked attribute of input checkboxes in this function.

A related issue, which might just be sloppy coding, the search form I'm working with hasn't given unique names to each checkbox, they put the identifier in the value field. An error message or an iterator for cases where each field doesn't have a unique name would be helpful.

An example of an html form with checkboxes where the unique identifier is in the value field and not the name (possibly out of scope for rvest to address):

hcsearchurl <- "http://www.healthycanadians.gc.ca/recall-alert-rappel-avis/search-recherche/advanced-avancee/"
hcform <- read_html(hcsearchurl) %>% html_node("form") %>% html_form()
@juba
Copy link

juba commented Jan 7, 2016

As a workaround, it seems you can "uncheck" a checkbox by assigning it a NULL value :

form <- set_values(form, checkbox_name = NULL)

@etabeta78
Copy link

I stumbled upon a similar problem last week, and I cooked up a solution that worked in all the cases I tried, by modifying the rvest set_value and submit_form (submit_request, in fact) functions so that they fill and acknowledge the "checked" field of the submission form options.

Pull request #132 contains my proposed fix, which also handles properly forms with multiple checkboxes sharing the same name.

@hadley hadley added feature a feature request or enhancement form 🧾 labels Mar 17, 2019
@hadley hadley closed this as completed in 9ba664b Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement form 🧾
Projects
None yet
Development

No branches or pull requests

4 participants