daattali / shinyalert

🗯️ Easily create pretty popup messages (modals) in Shiny
https://daattali.com/shiny/shinyalert-demo/
Other
241 stars 26 forks source link

Replace free text by closed input #40

Closed jlopezper closed 3 years ago

jlopezper commented 3 years ago

Thanks for this fantastic package.

I'm using shinyalert right now to collect feedback from users and store that information for analysis purposes. Now I'd like to change the free text mode to a closed input (something like radio buttons). In the documentation of the shinyalert function I see that in the inputType argument another valid HTML input can be specified. When I set this argument to "radio" it doesn't take up the text I specify in the inputValue argument:

image

Is this possible in shinyalert or is there a workaround?

Thanks in advance.

daattali commented 3 years ago

Radio buttons are not technically an input tag in html, so that won't work.

If you update to the latest version from last week, you can now pass any shiny code (including inputs like radioButtons()) into a shiny alert, take a look st the updated documentation

jlopezper commented 3 years ago

I think radio buttons are technically a html input tag.

daattali commented 3 years ago

Yes you're right. I was thinking about select inpiut dropdowns.

So technically a radio button would work, but wouldn't be very useful since it'll just show a single radio button, and radio buttons are only useful when you have multiple. Any of the input types that make sense as a single input would make sense in a shinyalert.

If you want radio buttons (or anything else that's beyond a simple single input) you can now do that since shinyalert now accepts any shiny UI, as the new documentation says.

jlopezper commented 3 years ago

Yes, perhaps this could be sorted out by allowing inputValue to be a character vector when inputType is set to be a radio button or checkbox, for example. In any case, I don't know what technical complexity this change would entail.

Thank you for your response. I will take a look at the latest version.

daattali commented 3 years ago

I don't think the underlying sweetalert javascript library would support a vector being passed in. As per their documentation, they simply say that inputType can be any input and inputValue will be the default value of the input (not the text beside the input, which makes me believe they don't explicitly support radio/checkboxes). In either case, I 100% recommend updating to v2.0 (just take note of the slight breaking changes in NEWS.md)