Building a full web form using Vue and Web Awesome
Previously, we learned how to build dropdowns, radio button groups, buttons, and combo boxes. I figure the next step is to put it all together and build a full web form. In today’s demo, we are going to build a “feedback” form where someone provides their name, contact information, and what they think of you. It doesn’t actually send it anywhere, but it shows the result, and it is easy enough to add something to record the results.
The last time around, we created https://grand-block-gar.codepen.app using the data files in https://github.com/steinbring/data/tree/main/v1/locations/us_states_municipalities_zctas to let the user select a state (using a list of suggestions), select a municipality (using a list of suggestions that are based upon the selected state), and select a zip code / postal code (using a list of suggestions that are based upon the selected municipality). In that demo, state management and form data are handled in App.vue, and the options for states, municipalities, and zip codes/postal codes use computed properties. ComboBox is imported from ComboBox.vue, accepts the properties “label”, “placeholder”, “disabled”, “options”, and “modelValue”, emits a new value for “modelValue” when the value of the web awesome combobox changes, and it only creates <wa-combobox> inside the component.
So, what are we doing this time? In this week’s demo, we are doing the same thing (the Web Awesome components are in Vue child components and the data and computed properties are in parent components), except the form itself is in a child of App.vue.
The form asks for your name, your opinion, your contact information, and your preferred contact method. If you select that you want to be contacted by phone, it uses the radio group element to ask about when you would like to be called.
To use the form “in anger”, you would want to add an API call to an endpoint that could send an email and/or save the submission to a database record. Since the web component is added to the Vue component, and the form elements’ Vue components are as generic as possible, swapping out Web Awesome for something like Bootstrap or Bulma is pretty easy.
Example: https://optimal-brook-eft.codepen.app
#VueJs #WebAwesome #WebComponents









