mark invalid forms in the summary page

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

mark invalid forms in the summary page

mbalazs
Hi Everyone!

I would like to accomplish the following: the form summary page should display which of the saved drafts contain validation errors. Like those rows should be highlighted with red, or a red asterisk mark should be visible, or there should be a separate column on the summary page which would show valid / invalid.

I guess that Orbeon can't do this out-of-the box, so I should implement it somehow.

My idea is that there would be a hidden field "is-valid" in the form, which I would set from an event handler when the user clicks save. And from the event handler, I would set it to true or false, accordingly to the result of the validation. And then the form summary should display this "is-valid" field as a column, but it shouldn't be visible as a field when editing the form.

I'm new to Orbeon, so I would be glad if someone could reinforce me that this would be the best way to do this, and to give me some pointers on how to actually implement it. (Which event to listen to, some examples to event handlers maybe)

Regards,
Miklos
Jez
Reply | Threaded
Open this post in threaded view
|

Re: mark invalid forms in the summary page

Jez
Hi Miklos

I would say you're on the right track. Yes a hidden field will get your 'is-valid' persisted and therefore available to be included on the Summary screen.

The validity of the form is held within the fr-error-summary-model within the fr-error-summary-instance as a boolean within the 'valid' element.

So if you had a control 'is-valid' within a hidden section 'hidden-section' you could include an action that populates the control and runs on save:

<xf:action ev:event="fr-data-save-prepare" ev:observer="fr-form-model" if="true()">
    <xf:setvalue ref="instance('fr-form-instance')/hidden-section/is-valid" value="xxf:instance('fr-error-summary-instance')/valid"/>
</xf:action>

Disclaimer: I don't know the roadmap for fr-error-summary-instance, so can't say whether this is supported going forward.

Regards

Jez
Reply | Threaded
Open this post in threaded view
|

Re: mark invalid forms in the summary page

Erik Bruchez
Administrator
That should probably work. But yes, this is using internal data structures so subject to change in the future.

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: mark invalid forms in the summary page

mbalazs
Yes, it seems to work! Thank you!

Miklos