Spring MVC - Can I Get Value Before Form Submit - spring-mvc

I'm using Spring MVC & Thymeleaf to make a form. I'm really curious if there's any way to get a form value before submitting?
What I mean is like inputting a Country on the country dropdown field & when I'm about to fill the next field, which is the City dropdown field where the field used to be disabled before I filled the country field, the field after filling the country field will be enabled & the dropdown only shows cities correspond to the country I filled.
Btw sorry I don't share code for this question because I think it's a general question & I already use a database so I might need DISTINCT syntax since there's a lot of duplicate values on the database. And if there's no way to do all of these with Spring + Thymeleaf, I'm open to hear suggestions with other frameworks or even Javascript.

Related

Conditionally loading multiple fields with multiselect with Caldera Forms for Wordpress

Good day,
I've been looking around for a solution to my problem, but could not find it documented anywhere. Feel free to link to another thread if useful.
I'm building a form on Wordpress using Caldera Forms. In this form, I have a multiselect dropdown for which each selection should show dynamically an extra field. Unfortunately, I cannot load more than one conditional field when selecting multiple values. It will only load the first field populated by the condition of my first selection.
Try it out:
Open https://34.95.27.135/test-caldera/
On the "Role" field, select "Software Engineer"
This should populate a "Top Skills" field
On the "Top Skills" field, if you autocomplete ANY of the options, the first condition is met and you will see the right field for it
Selecting more options from the "Top Skills" field should be populating other fields, but instead, it flicks in the view and then only shows the first met conditional field.
Anyone has had this issue? Was there anything special to do on the Conditions tab to make it work as intended?
You may Import this form by importing this JSON:
{"_last_updated":"Sun, 19 Jan 2020 23:23:23 +0000","ID":"CF5e213a11b5adc","cf_version":"1.8.9","name":"Career Matrix","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_97450":"1:1","fld_5750655":"1:1","fld_4465116":"1:1","fld_2852708":"1:1"},"structure":"12"},"fields":{"fld_97450":{"ID":"fld_97450","type":"filtered_select2","label":"Top Skills","slug":"your_top_skills_software_engineer","conditions":{"type":"con_9081220263929126"},"required":1,"caption":"Select your top skills.","config":{"custom_class":"","placeholder":"","multi":1,"color":"#5b9dd9","border":"#4b8dc9","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","show_values":1,"option":{"opt2039319":{"calc_value":"x","value":"x","label":"x"},"opt2036344":{"calc_value":"y","value":"y","label":"y"},"opt2092176":{"calc_value":"z","value":"z","label":"z"}},"email_identifier":0,"personally_identifying":0}},"fld_4465116":{"ID":"fld_4465116","type":"star_rating","label":"z Proficiency","slug":"z_proficiency","conditions":{"type":"con_4202235771498248"},"caption":"Rate your z proficiency","config":{"custom_class":"","default":"","number":5,"type":"star","size":13,"space":3,"color":"#FFAA00","track_color":"#AFAFAF","email_identifier":0,"personally_identifying":0}},"fld_2852708":{"ID":"fld_2852708","type":"star_rating","label":"y Proficiency","slug":"y_proficiency","conditions":{"type":"con_6383484066940033"},"caption":"Rate your y proficiency","config":{"custom_class":"","default":"","number":5,"type":"star","size":13,"space":3,"color":"#FFAA00","track_color":"#AFAFAF","email_identifier":0,"personally_identifying":0}},"fld_5750655":{"ID":"fld_5750655","type":"star_rating","label":"x Proficiency","slug":"x_proficiency","conditions":{"type":"con_5108268722503233"},"caption":"Rate your x proficiency","config":{"custom_class":"","default":"","number":5,"type":"star","size":13,"space":3,"color":"#FFAA00","track_color":"#AFAFAF","email_identifier":0,"personally_identifying":0}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"dube25#gmail.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Career Matrix","email_message":"{summary}"},"conditional_groups":{"conditions":{"con_5108268722503233":{"id":"con_5108268722503233","name":"SE x Skill","type":"show","fields":{"cl6611176254177354":"fld_97450"},"group":{"rw1073423041345211":{"cl6611176254177354":{"parent":"rw1073423041345211","field":"fld_97450","compare":"is","value":"opt2039319"}}}},"con_6383484066940033":{"id":"con_6383484066940033","name":"SE y Skill","type":"show","fields":{"cl4932869345780543":"fld_97450"},"group":{"rw2445485636298987":{"cl4932869345780543":{"parent":"rw2445485636298987","field":"fld_97450","compare":"is","value":"opt2036344"}}}},"con_4202235771498248":{"id":"con_4202235771498248","name":"SE z Skill","type":"show","group":{"rw3854064841859657":{"cl7317560418250427":{"parent":"rw3854064841859657","field":"fld_97450","compare":"is","value":"opt2092176"}}},"fields":{"cl7317560418250427":"fld_97450"}}}},"settings":{"responsive":{"break_point":"sm"}},"privacy_exporter_enabled":false,"version":"1.8.9","db_id":"19","type":"primary"}
Thank you very much!

Dropdown Widget and Related Model

I have two models, Country and City and a one-to-many relationship between them. One country can have many cities and a city can only have one country. App Maker generates a Country_fk field in the City model.
Now when I create a Create form and drop a form bound to the City model and include the related Country field App Maker creates a dropdown with the following:
options: #datasources.Country.items
value: #datasource.item.Country
Which, if I compare it with some example apps looks absolutely fine. However, I only get the Id of the related Country field not the country name field.
This has happened so many times with different models. I did once manage to create a relationship that worked, and it used the same datasource options and value values, but I can't for the life of me see why something so simple as this is so hard to do. it is so basic newbie stuff I'm beginning to give up on App maker.
You can use a little bit of help from the official documentation.
When you create a model, you can select the default display field. App Maker uses the default display field when it refers to a record in the model. A display field is commonly used for widgets that select a record, such as dropdowns.
Go to your model and make sure you select the proper display field. Something similar like in the image below.
You need to make the required field the 'Display Name' in the relevant model. Once you do this it will display as you want šŸ‘

CountrySelect form field, pre-populate with a country

How can I default to populating the Select drop down list with a value, in this case it would be the country U.S.. We've removed other countries from the list but users are still required to select the one option.
In addition to a default value, the dependent fields would need to be populated. Currently in Intershop, selecting the country populates the State field. I would like to default to U.S. and have the State field already populated on the initial request, sans ajax calls.
You would have to modify some pipelines for this.
The webform it loads is based in the country code. Intershop gets the countrycode from the addressbo or as a parameter. See the ViewUserAccount-ChangeAddress : this pipeline is used in the ajax request to load the webform when u select a country. You could use the same logic to load the U.S webform (US) when the address has not been filled in yet.

user input forms with user defined fields

Ive been tasked with creating a user input form that has a set of defined fields and the ability for the user to add their own fields on the fly. e.g textbox, select box with options etc etc. Has anyone got any ideas on how i could implement this. What do i need to consider?
Also How would i store the data as i wont know the amount of fields. Generally in past projects a field in the input form has mapped to a column in the database.
Any ideas
Thanks in advance
It will need to be stored in a denormalised fashion:
QuestionField
AnswerField
So you'll probably need a Questions table which defines the question and maybe the type of input and any contraints.
You'll then have an answers table which is linked to whatever your entity is. The answers table will have an question and an answer field.
Do your users log into your site? If so you could use a SQL table to store each users controls e.g. :
UserName ControlID ControlType
JohnSmith 1 TextBox
JohnSmith 2 CheckBox
JoeBlogs 3 TextBox
You can then have another table with each controls value within it:
ControlID Value
1 My Text Value
2 False
3 Hi Iā€™m Joe
You can then just do a simple join to get all the users controls and there values. You can also store information such as location/index of the control on screen. Doing it this way you can add more than one value per control, meaning things like list box's will have multipul rows.
If your not using a log in system you could do the same sort of thing but using Cookies.

Display data from database using selected value from combo list.. (ASP)

Does anyone know how to retrieve and display data from database using combo list? What I mean is this..I have a form..in the form there is a combo list and two textfiels..the user need to choose their company using that combo list..once they have chose their company, the address and contact number of the company will be display in the next two textfields called CAddress and CContact..for example, if the user chose company ABC..how can I display the company ABC address and contact number in those textfields? Need help. Thanks.
first of all you could use javascript and make a call ajax to an asp page passing the id of the company ... in that page you can jsut response.write the infos u need as a xml format ... even csv format would work ... then jsut take the response and write it in the textbox

Resources