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

Customize Next Button to add validations #8

Open
nikhil-nomula opened this issue Feb 11, 2020 · 7 comments
Open

Customize Next Button to add validations #8

nikhil-nomula opened this issue Feb 11, 2020 · 7 comments

Comments

@nikhil-nomula
Copy link

Hi,

Is it possible to make validations when user clicks on Next and go to next screen only if the validations pass?

@juba
Copy link
Owner

juba commented Feb 11, 2020

I'm not sure I understand your request. You would like the button not to be disabled, but the validation to take place when the user clicks Next ? Is there a particular reason you would like this feature ?

@nikhil-nomula
Copy link
Author

Ah ok, for e.g. I have a form where user enters, and then when he/she clicks next, what I want to do is in server.ui, perform validations and then display modal if validations fail, if not go to next screen.

Does that make sense?

@juba
Copy link
Owner

juba commented Feb 11, 2020

Ah, I think I understand. Unfortunately no, this is not possible right now, if validation fails the "next" button is inactive, there's no way to perform the check at click time. And given the complexity it took to implement the current validation system, I'm not sure I would be able to modify it...

@nikhil-nomula
Copy link
Author

Got it, I understand. It is a pretty good package. The workaround I am planning to do is, have an extra button on screen, have user click it and then perform validation, use a reactive variable in server.R and then show the next button in ui.R based on that. That should be possible right?

@juba
Copy link
Owner

juba commented Feb 11, 2020

Hmm maybe you could use an hidden input that you would update only if the form is submitted and valid, and add a validation condition on the next button based on this hidden input value ? By using disable_type = hide the next button would be hidden instead of inactive.

@juba juba closed this as completed Feb 15, 2020
@samssann
Copy link

I think this feature would be highly appreciated. You could register the following input bindings and functions

input$next_button # observed when next is clicked
input$prev_button # observed when prev is clicked
next() # moves to next screen
prev() # movest to previous screen
input$screen_number # (integer) id of the screen, updates on next() or prev()

Then people could run custom validations e.g.

observeEvent(input$next, {
  if(input$screen_number == 1L) {
     ...
  } else if(input$screen_number == 2L) {
     ...
  }
  next()
})

But yeah, this is essentially the same functionality the package already has (with js), but with maybe a bit more control for the user. Server side validation would be huge.

@juba
Copy link
Owner

juba commented Feb 27, 2020

Hm, I see how this could indeed be quite useful, I didn't think of it this way.

I'm reopening the issue and will try to take a look at it (but with no ETA I fear...)

Thanks for the clarification.

@juba juba reopened this Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants