Fork me on GitHub
#reagent
<
2017-11-19
>
gonewest81820:11:59

beginner question here… I’m using the soda-ash wrappers for Semantic UI React to create a web form. I want the form to have a dropdown selection and two text inputs. In this particular case I just need the form submit to do a GET with input values as url parameters. But the Semantic UI “Select”’s value never appears as a url parameter no matter what I try. How should I approach this?

gonewest81820:11:20

As a workaround I’m just using a [:select ...] inside the form element along with the two sa/Input elements. That at least works, but it’s visually hideous.

mikerod21:11:32

@gonewest818 Perhaps it’d be easier to help if you could show what you have

mikerod21:11:36

At least the main idea of it

gonewest81822:11:53

[:form
       [sa/Input {:name "foo"
                  :on-change   #(reset! s (-> % .-target .-value))
                  :value       @s}]
       [:select {:name "bar"}
        [:option {:value "a"} "A"]
        [:option {:value "b"} "B"]]]

gonewest81822:11:41

is the gist of what I have, but what I want is to exchange the :select with a sa/Select or similar and I want the selection bound to an atom so I can do some validation across the fields, because the selection “bar” and the input “foo” need to be mutually valid in a particular way I can compute.

gonewest81822:11:04

(Not at the laptop right now, so this is from memory I’ll be more specific when I get back)

mikerod22:11:40

@gonewest818 thanks. Trying to see if I can notice anything useful to say here.

mikerod23:11:01

@gonewest818 I looked at it some, but I’m not sure enough on what you are expecting to happen. Do you have something set for your :form :on-submit or the :action? Are I don’t see a “submit” sort of button in this example either. Perhaps I’m missing something. Also, it looks like there is a sa/Form component that I believe you’d use instead of the React :form.

gonewest81823:11:52

Ah, yes there is a submit button as well as (by default I guess?) a “enter” in the input fields seem to cause a submit also. There is a sa/Form but it doesn’t seem to be a <form> under the hood, and I couldn’t figure out how to get the submit action to be a “GET /?foo=a&bar=b”.

gonewest81823:11:34

I guess that’s another way to phrase my question: how do I declare a handler for :onsubmit (or whichever the appropriate event is) that constructs the url parameters based on whatever atoms I need, and performs the “GET /?foo=a&bar=b” like a generic HTML form would do?