Sending additional info with form submission/save

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Sending additional info with form submission/save

pc3356
Hi,

We're trying to implement a "save as draft" piece of functionality. When a user saves the form, they will be able to see any form validation errors, but the form will still be submitted along with a flag (maybe a header or something) to say that it failed validation.

We are using Orbeon Forms 4.0 with our own HTTP-based custom persistence engine.

Is this something we could do easily? If so, how/where should we be looking? We are fairly new to Orbeon Forms...

We have been trying to add things to epilogue.xpl, but this doesn't seem to have been working for us.

Many thanks,

Phil.
Reply | Threaded
Open this post in threaded view
|

Re: Sending additional info with form submission/save

elson
We have already changed the configuration setting which allows users to save invalid data, that works fine. We just need to somehow let our custom persistence API know that the data being submitted is valid or invalid.

Could we do something with the xxforms-valid or xxforms-valid events, perhaps adding a header along to the persistence API? If altering the call to the API is not possible, maybe we could add an attribute to the root element indicating the validation state. It's a bit dirty, but might work.

Any suggestions on how to do that, or something similar, would be greatly appreciated :)

Thanks,
Steve

On Thursday, 18 April 2013 15:47:11 UTC+1, philip.coates wrote:
Hi,

We're trying to implement a "save as draft" piece of functionality. When a
user saves the form, they will be able to see any form validation errors,
but the form will still be submitted along with a flag (maybe a header or
something) to say that it failed validation.

We are using Orbeon Forms 4.0 with our own HTTP-based custom persistence
engine.

Is this something we could do easily? If so, how/where should we be looking?
We are fairly new to Orbeon Forms...

We have been trying to add things to epilogue.xpl, but this doesn't seem to
have been working for us.

Many thanks,

Phil.

--
View this message in context: http://discuss.orbeon.com/Sending-additional-info-with-form-submission-save-tp4656592.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Sending additional info with form submission/save

Alessandro  Vernet
Administrator
Hi Steve,

One way of doing it would be to create a hidden field, with visibility set to false(), so it's never visible or editable by end users, and having the following calculated value:

xxf:instance('fr-error-summary-instance')/valid

This way the whether the form is valid or not is stored as part of the form data.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Sending additional info with form submission/save

richonlyne
We managed to resolve this in a bit of a hacky way:

In the persistence-model.xml we changed

<xf:submission id="fr-create-update-submission"...
    ...
    ...
    resource="/fr/service/persistence/crud/{$app}/{$form}/data/{$document}/{event('resource')}"
    ...
/>


to read:


<xf:submission id="fr-create-update-submission"
    ...
    ...
    resource="/fr/service/persistence/crud/{$app}/{$form}/data/{$document}@@{if(xxf:instance('fr-error-summary-instance')/valid = 'true') then 'Valid' else 'Draft'}/{event('resource')}"
    ...
/>


This allows our custom persistence layer to parse the Orbeon Id (the {$document} part) and retrieve both Orbeon Id and the form validation status. @ was the only character from a bunch I tried other than alphanumerics that could pass the url validation.

This avoided having to create hidden fields that would need to be removed when persisted and added when editing content again whilst also having minimal impact on the Orbeon code.
Reply | Threaded
Open this post in threaded view
|

Re: Sending additional info with form submission/save

Alessandro  Vernet
Administrator
Rich,

Note that this will come out-of-the-box in 4.2, and incidentally your change to persistence-model.xml won't work anymore. Whether the document is valid or not will be passed as a request parameter to the persistence layer (i.e. valid=true). And this code moved from persistence-model.xml to Scala code in SimpleProcess.scala.

https://github.com/orbeon/orbeon-forms/blob/master/src/main/scala/org/orbeon/oxf/fr/SimpleProcess.scala

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Sending additional info with form submission/save

richonlyne
Thanks for the heads up about 4.2 Alex.

As a heads up for others that choose to look at this as a temporary solution, both saving form content and saving a form will append the @@Valid or @@Draft to the id (in this example).

Rich.