Skip to content

Instantly share code, notes, and snippets.

@orbeon
Created September 23, 2021 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orbeon/f0a46e1dd6a3227c5e4d555e01f479ed to your computer and use it in GitHub Desktop.
Save orbeon/f0a46e1dd6a3227c5e4d555e01f479ed to your computer and use it in GitHub Desktop.
Orbeon Forms - Workflow - Employer and employee filling different section
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:array="http://www.w3.org/2005/xpath-functions/array"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
fr:data-format-version="4.0.0">
<xh:head>
<xh:title>Application</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true" xxf:analysis.calculate="true">
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all" xxf:index="id">
<form>
<employer-section>
<grid-1>
<company-name/>
<fill-employee-section>false</fill-employee-section>
<employee-email/>
</grid-1>
</employer-section>
<employee-section>
<grid-2>
<first-name/>
<last-name/>
</grid-2>
</employee-section>
</form>
</xf:instance>
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="employer-section-bind" name="employer-section" ref="employer-section"
readonly="fr:workflow-stage-value() != ''">
<xf:bind id="grid-1-bind" ref="grid-1" name="grid-1">
<xf:bind id="company-name-bind" name="company-name" ref="company-name"
xxf:whitespace="trim"
required="true()"/>
<xf:bind id="fill-employee-section-bind" ref="fill-employee-section"
name="fill-employee-section"
type="xf:boolean"/>
<xf:bind id="employee-email-bind" ref="employee-email" name="employee-email"
type="xf:email"
xxf:whitespace="trim"
relevant="$fill-employee-section/string() = 'false'"
required="true()"/>
</xf:bind>
</xf:bind>
<xf:bind id="employee-section-bind" ref="employee-section" name="employee-section"
relevant="$fill-employee-section/string() = 'true' or&#xA;(fr:mode() != 'new' and fr:workflow-stage-value() != '')"
readonly="fr:workflow-stage-value() = 'employer-and-employee'">
<xf:bind id="grid-2-bind" ref="grid-2" name="grid-2">
<xf:bind id="first-name-bind" ref="first-name" name="first-name" xxf:whitespace="trim"
required="true()"/>
<xf:bind id="last-name-bind" ref="last-name" name="last-name" xxf:whitespace="trim"
required="true()"/>
</xf:bind>
</xf:bind>
</xf:bind>
<xf:instance id="fr-form-metadata" xxf:readonly="true" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>gov</application-name>
<form-name>application</form-name>
<title xml:lang="en">Application</title>
<description xml:lang="en"/>
<created-with-version>2020.1-SNAPSHOT PE</created-with-version>
<updated-with-version>2020.1-SNAPSHOT PE</updated-with-version>
<email>
<subject>
<template xml:lang="en">Application form</template>
</subject>
<body>
<template xml:lang="en">Your employer, {$employer}, requested that you fill out the employee section of the following form:
{$link}</template>
<fr:param type="ControlValueParam">
<fr:name>employer</fr:name>
<fr:controlName>company-name</fr:controlName>
</fr:param>
<fr:param type="LinkToEditPageParam">
<fr:name>link</fr:name>
</fr:param>
</body>
</email>
</metadata>
</xf:instance>
<xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
<attachments/>
</xf:instance>
<xf:instance xxf:readonly="true" id="fr-form-resources" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<first-name>
<label>First name</label>
<hint/>
</first-name>
<last-name>
<label>Last name</label>
<hint/>
</last-name>
<employer-section>
<label>Employer</label>
</employer-section>
<employee-section>
<label>Employee</label>
</employee-section>
<company-name>
<label>Company name</label>
<hint/>
</company-name>
<fill-employee-section>
<label>Fill employee section</label>
<hint/>
</fill-employee-section>
<employee-email>
<label>Employee email</label>
<hint/>
</employee-email>
</resource>
</resources>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:oxf="http://www.orbeon.com/oxf/processors">
<fr:section id="employer-section-section" bind="employer-section-bind">
<xf:label ref="$form-resources/employer-section/label"/>
<fr:grid id="grid-1-grid" bind="grid-1-bind">
<fr:c y="1" x="1" w="6">
<xf:input id="company-name-control" bind="company-name-bind">
<xf:label ref="$form-resources/company-name/label"/>
<xf:hint ref="$form-resources/company-name/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</fr:c>
<fr:c y="1" x="7" w="3">
<fr:yesno-input xmlns="http://orbeon.org/oxf/xml/form-builder"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
id="fill-employee-section-control"
bind="fill-employee-section-bind">
<xf:label ref="$form-resources/fill-employee-section/label"/>
<xf:hint ref="$form-resources/fill-employee-section/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</fr:yesno-input>
</fr:c>
<fr:c x="10" y="1" w="3" h="1">
<xf:input id="employee-email-control" bind="employee-email-bind"
class="fr-email-recipient">
<xf:label ref="$form-resources/employee-email/label"/>
<xf:hint ref="$form-resources/employee-email/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</fr:c>
</fr:grid>
</fr:section>
<fr:section id="employee-section-section" bind="employee-section-bind">
<xf:label ref="$form-resources/employee-section/label"/>
<fr:grid id="grid-2-grid" bind="grid-2-bind">
<fr:c x="1" y="1" w="6">
<xf:input id="first-name-control" bind="first-name-bind">
<xf:label ref="$form-resources/first-name/label"/>
<xf:hint ref="$form-resources/first-name/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</fr:c>
<fr:c x="7" y="1" w="6">
<xf:input id="last-name-control" bind="last-name-bind">
<xf:label ref="$form-resources/last-name/label"/>
<xf:hint ref="$form-resources/last-name/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</fr:c>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
<properties xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:oxf="http://www.orbeon.com/oxf/processors">
<property as="xs:string" name="oxf.fr.detail.buttons.gov.application" value="submit"/>
<property as="xs:string" name="oxf.fr.detail.process.submit.*.*">
require-uploads
then validate-all
then
if ("fr:workflow-stage-value() = '' and
//fill-employee-section/string() = 'false'")
then (
email then
set-workflow-stage(name = "employer-only")
) else (
set-workflow-stage(name = "employer-and-employee")
)
then save
then navigate(uri = "/fr/static/submitted/new")
recover error-message("database-error")
</property>
<property as="xs:string" name="oxf.fr.detail.button.submit.visible.gov.application"
value="fr:workflow-stage-value() != 'employer-and-employee'"/>
<property as="xs:string" name="oxf.fr.detail.buttons.static.submitted" value=""/>
<property as="xs:boolean" name="oxf.fr.email.attach-pdf.*.*" value="false"/>
<property as="xs:boolean" name="oxf.fr.email.attach-xml.*.*" value="false"/>
</properties>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment