how to reset part of form in orbeon - web-services

Is it possible to simply reset form controls (inluded checkboxes, selections, repeatable compontents, text inputs)? (when web service return some data I want to reset some part of form to get possilibity to add new data via web service - I invented it to replace nested repeatable grids).

There is not much that can't be done by writing custom XForms code, but out of the box it's only possible to clear the whole form with the "Clear" button.

Related

Saving ModelForm progress values to session in Django

I have flow where users can create (model) forms. If form is valid, object gets saved and flow continues, but selection is in multiple pages. I need to keep current state of created object, which cannot be saved before it's completely valid.
One thing I can do is to always pass things around those views in the ModelForm to make sure, that user never loses data, but I also wanna make sure, that if he leaves the flow and comes back, he doesn't lose data, that he already entered previously.
That's why I decided I wanna save all the fields to session.
Is this correct approach?
How would you do this?
Where would you put this session logic?
What's best way of getting the fields from incomplete form to be saved?
Edit:
Please don't give me advice on how to use session, I am talking more about high level logic and architecture than specific implementation.
I should describe my flow a bit more. Model has 3 fields.
normal dropdown (foreign key referencing another model)
textfield
another foreign key, but this time not done by select, but it's own separate page with lots of filters to help user pick the right (foreign) model
Flow is not linear, because user can start in different parts of page.
Sometimes user can go to page, where he has first 2 fields + button "Browse", which takes you to selection page for 3rd field. Then after he selects field there, he comes back.
But sometimes he selects first this field and then comes to screen with 2 remaining fields, where he needs to fill those.
django-formtools offers a great way to do this using Form wizard.
The form wizard application splits forms across multiple Web pages. It
maintains state in one of the backends so that the full server-side
processing can be delayed until the submission of the final form.
More info here https://django-formtools.readthedocs.io/en/latest/wizard.html
to save in session:
request.session["variable_name"] = "value"
to get from session request.session["variable_name"]. sure you can use request.session.get("..") in both too

Show field based on another fields value using rules, WFFM, Sitecore8.1

I want to conditionally show a field in a web forms for marketers form in Sitecore 8.1.
My thoughts was that rules could be utilized to that. the only problem is that it seemingly does not work.
When I set a field to conditionally hide based on the value of another field, nothing happens when I satisfy the condition ie. enter the conditional value.
My intuition here is that the rule editor is not working on realtime on the form (by using JavaScript) but is only something that runs on the server.
Can anybody confirm this? Or otherwise send me the right direction towards realtime updating the form based on rules?
Greetings Mads Buch
You will require to use Javascript. What you can do is to create a custom rule which will be triggered via javascript. You can check the following link on how to create a custom rule https://jeffdarchuk.wordpress.com/2015/06/04/lets-use-that-rules-engine/
Also, you may create a custom type as suggested in this thread.
Thanks

Django multi-select widget. Add arbitrary select components

i would like to make a widget that lets the user select a value from a drop-down list and then add new drop-down lists with values filtered based on the previous selections. I don't know where to start from....
If the amount of drop-downs is finite and determinable by the time you develop the software (e.g. selecting country->city->street) I would suggest to:
add all the extra dropdowns (without data yet) to your form, make sure they are hidden
use jqueryui to un-hide and populate the dropdowns as needed using ajax
Don't forget to disable/hide the whole form by default and only show it if JS is enabled in browser.
Also, you will of course need another view, with which only ajax speaks.
Here for you to catch the idea how the stuff should work. Sorry don't know if they have anything more similar. But: user selects something -> jquery requests data for the next dropdown -> jquery displays next populated dropdown.

Sitecore Webforms for Marketers - one form, multiple screens

Is it feasible to have a form in WFFM that has multiple "screens"? For instance in the first "screen" you enter some information and click NEXT, then the second "screen" asks you to confirm the information you entered in the first screen, and then the user clicks SUBMIT and the action (i.e. saving to DB) is performed.
Thanks,
FG
This kind of functionality is not supported out of the box. Whenever we run into cases like this we tend to build our own custom forms using standard .net functionality. I guess this would be the way to go for you aswell, since you will have more control over the behavior of different elements. WFFM is a good module but for special elements as you describe above you could best build your own custom code.

where do functions that don't display go in django

I have some links on an html page like , , currently I handle them as so
<p> rate down
and have a url.py entry:
(r'^cases/(?P<case_id>\d+)/case_rate/(?P<oper>.)$', 'mysite.cases.views.case_rate'),
then I have a view function that handles the logic and hits the DB, then does this:
return HttpResponseRedirect(request.META.get('HTTP_REFERER','/'))
I's there a better way to do this? I can see how this would be OK because it does have to redraw the screen to show the new rating...
The typical way to handle this is with an ajax request.
Instead of a link, you put a javascript handler that calls a view, wich updates the db, and returns a json / xml object with the new rating for the item. Then another javascript handle receives that response and updates the rating number on the screen, without a page reload.
Ideally, you'll keep both versions: plain html (the one you currently have) and the ajax one. The ajax one can be attach to the element after page load, so if javascript is not available, you'll still have a working site.
Then, regarding organization, you can have an "ajax" parameter on your view. The view should update the db accordingly, and if it's an ajax call, return the json / xml response, otherwise, return the new page. That way you can keep the logic (fetching the object, updating the db) on one place.
If you're asking whether case_rate should still go in the views.py given that it returns a redirect rather than providing content, the answer is yes, since case_rate is handling an request and returning a response.
But consider a situation where you had two view functions in views.py that had some duplicate code, and you chose to factor that duplicate code into another function that didn't both take request and return a response. Would that be fair game to leave in views.py? Sure, if moving it elsewhere would make the code harder to read. Or you might choose to put it elsewhere. It's really your call based on your sense of taste.