How to keep track of selections in sequential form - ruby-on-rails

I have what is essentially a form, only the fields depend on the previous selections, and the type of form object aren't always typical form objects.
For example, the first choices are simply in the form of links. It could be a list of teachers, where when you select a teachers name, the classes that teacher teaches is then displayed in a drop-down list. Then once a class is selected, the available dates and time are displayed in a calendar. Once a date/time is selected I need to know all of the selections that were made -- the teacher, the class, and the date and time.
How would you recommend keeping track of these selections? I'm using ajax, and although the form fields are hidden at times, i can still access their values. The one exception is the teacher selection. Since it's just a link, I pass the selected value to a method, but then I've lost the selection. I could store the selection in a hidden field, but is that really the best solution?
Thanks!

I would use a session store on a controller action. Then once it's complete extract all the gathered information.

Related

User input in repeated grid to fill dynamic dropdown

I am building an Orbeon form where people can add information to a repeated grid, e.g. Name, Age.
Later in the form, there will be a 'Friend' section that will reuse data from the repeated grid.
I can synchronize the data using <fr:synchronize-repeated-content>, but is it possible to reuse the data from the repeated grid in a dynamic dropdown instead?
A dynamic dropdown could make this form much shorter, compared to <fr:synchronize-repeated-content>, as only a few of the rows in the repeated grid will need more data later in the form (only few friends from a long list of names in the repeated grid).
It is currently not possible for this form to use any web services.
Currently, you can't directly populate a dropdown based on data entered in a repeated grid earlier in the form. As you suggested, using another repeated grid and <fr:synchronize-repeated-content> is a workaround. But being able to directly populate a dropdown would definitely make sense, and this is covered by request for enhancement 4182.

Active Choices: Single Map backing two single-select dropdowns

I have a set of data that is returned as a single JSON blob that deserializes into a map. The keys of the map should back one dropdown, and the values of each key are an array of strings that, when that key is chosen in the first dropdown, populate the second dropdown. Changing the first dropdown should repopulate the second with the new set of values corresponding to the array that is the value of the new key.
['foo': ['bar','baz'], 'zoo': ['rab','zab']]
The above data should have one dropdown with 'foo' and 'zoo' as choices. When 'foo' is chosen, the other dropdown should have 'bar' and 'baz'. If 'zoo' is chosen, the other dropdown should change to 'rab' and 'zab'.
I don't want to make the API call more than once as it's not a cheap call, but I am having trouble figuring out if it's possible to back two controls with a single map... I know that I can use reactive controls to make one change based on the value in another dynamically, but not how to have both looking at one data structure.
Either I'm missing something silly, or it's not possible. I'm not sure which it is.

How to auto populate specific Google Form fields, based on dropdown choice

I use Google Forms regularly at work, and I think they are awesome, especially since I am a total newbie with coding. With a few good plugins for Forms and Sheets, I am able to generate contracts, invoices, and so on very easily, based on document templates.
To keep it short, here is my request:
I have a form, where I input the customer's details, and upon submission, an addon generates a gdoc, based on a template. Al working great so far. My problem is that we are generating many different documents for a single customer, so it becomes a repetitive and very time-consuming task, considering that I have 15-20 different input fields for a customer, plus specific input fields for each different document.
The first input filed in my form is "Customer Name" and I have managed to create a dynamic dropdown list, that takes it's information from a specific column in a Google Sheet.
My request: how could I auto populate specific input fields in my Google Form, so that, based on my dropdown choice, the auto completed information will match the corresponding row present in the Google Sheet.
I have attached 2 images for easier understanding:
You can actually do this with a simple vlookup:
note: I also always wrap my functions with and if statement that checks if there is text in the first field, so try:
pretend that your dynamic customer name is in cell A1:
customer vat formula -
=IF(ISTEXT(A1),VLOOKUP(A1,'Parteneri'!A:C,2,FALSE),)
customer city formula -
=IF(ISTEXT(A1),VLOOKUP(A1,'Parteneri'!A:C,3,FALSE),)

Dynamically Changing Simple Form Select on Another Select Change

I have a requirement to modify a select box based on changes made in a previous selection.
In this case I have a simple_form form with a country selection. If a user selects a particular country, a second select field will contain business entity types for the selected country.
For example, in Australia you'd have Sole Trader, Pty Ltd, etc. In the US, you have LLC, S Corp, C Corp, etc.
What I need is to be able to dynamically change the second selection box when the user chooses or changes the selected country.
I'd appreciate your suggestions on how to proceed. I'm using Rails 4 with jquery. Is JavaScript the best/only way to go here, or are their other options for doing this with Rails? Cheers.
Javascript/Jquery is the best way to do this. Bind a change event to your country select list and based on selected country, change the option tags of business entity
Hope this helps!

Generating values for dropdown ONLY for 'C' of CRUD

When choosing 'Add' in CRUD, how best to generate a list of choices to pick from a dropdown?
For U/update - just display what's there...
The field contents starts with a letter, followed by five numeric digits:{A-I,K-N,Z}#####
Each letter has a different 'max' value for the numeric part.
So when adding a new record, I'd like to offer a listbox with one of each letter and that letter's highest numeric value + 10.
So, if the max 'A' as A00120, and max 'B' B00030 (etc) the listbox would have A00130 and B00040.. etc
Save the user having to figure out which is 'next' when generating a new record.
? Thanks,
Mark
This time I'll not be able to come up with ready to use solution, but I must say - everything is possible with ATK4. You just have to customize and extend it to fit your needs :)
Speaking about your question above - I guess you have to split it in multiple parts.
First part is about how to show select box on Create and readonly or disabled field on Update. I guess you can make some custom Form field or pin some action to existing Form Field hook. Not sure exactly what's better in this case.
Second one is about data structure. I believe that this field actually should be 2 fields in DB and maybe (only maybe) merged together in ATK model with addExpression() just for user interface needs to display these 2 fields as one field easily in UI. Maybe such concatenated field will be useful also for searching, but definitely not as only one field stored in DB. Imagine how hard it'll be for DB engine to find max value if such field. Store it like type = letter, num = number and then search like SELECT max(num)+10 FROM t WHERE type='A'
Finally Third part is about how to generate this next number. I read your question 3 times and came to conclusion that actually you don't have to show this +10 numeric value in UI at all if it's hardly predefined anyway. Actually that'll not work correctly if this will be multi-user system which I guess it will. Instead just show simple select box with letters {A-I,K-N,Z} and calculate this next value exactly before inserting data in DB. That can be done using models insert hook. This will be much more appropriate solution and will be better for UI and also more stable because calculated in model not incorrectly in UI part.

Resources