Custom Form Builder Publish Behaviour

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

Custom Form Builder Publish Behaviour

kiskandar
This post was updated on .
Hi All

We're currently looking to customise the behaviour of the publish button in the Form Builder. Looking at the current code in Form Builder:

xf:show(
    dialog = "fb-publish-dialog",
    app    = "{xxf:instance('fb-form-instance')/xh:head/xf:model[@id = 'fr-form-model']/xf:instance[@id = 'fr-form-metadata']/*/application-name}",
    form   = "{xxf:instance('fb-form-instance')/xh:head/xf:model[@id = 'fr-form-model']/xf:instance[@id = 'fr-form-metadata']/*/form-name}"
)

We don't want to show the dialog box to the users. We instead want to just trigger the behaviour below which is taken from Orbeon's code when clicking on the Publish button in the dialog. Apart from triggering the default publish behaviour below we also want to pass in a custom parameter to the publish process.

<xf:trigger xxf:modal="true" id="fb-publish-publish" appearance="xxf:primary">
    <xf:label value="$form-resources/dialog-publish/publish"/>
    <xf:action event="DOMActivate">
        <xf:dispatch name="fb-publish-form" targetid="fr-form-model">
             <xf:property name="doc"                      value="xxf:instance('fb-form-instance')"/>
             <xf:property name="app"                      value="$app"/>
             <xf:property name="form"                     value="$form"/>
             <xf:property name="document-id"              value="$document" model="fr-persistence-model"/>
             <xf:property name="form-definition-version"  value="instance()/selected-version/string()"/>
             <xf:property name="version-comment"          value="instance()/selected-comment/string()"/>
             <xf:property name="available"                value="not(instance()/available = 'false')"/>
        </xf:dispatch>
    </xf:action>
</xf:trigger>

Would all this be doable?

Kind regards
Kris
Reply | Threaded
Open this post in threaded view
|

Re: Custom Form Builder Publish Behaviour

Alessandro  Vernet
Administrator
Hi Kris,

I gather that you'd like to do what publish does out-of-the-box, minus the
dialog, plus "a parameter". (I'd be interested in knowing more about the
latter, but let's ignore this for now.) Here is what I would try:

- Add a custom model, so you can "inject" your own logic into the form, in a
separate file you own (see 1st link below).
- In that custom model, add an event hander for your own event
`kris-publish`. When you get the event, dispatch `fb-publish-form` as done
in the snippet you quoted (plus, I imagine, passing your parameter).
- In your `properties-local.xml`, override
`oxf.fr.detail.process.publish.orbeon.builder` to use the `xf:dispatch`
action to run your handler (see 2nd link below).

You'll let me know if this looks like something that could work for you.

https://doc.orbeon.com/form-runner/advanced/custom
https://doc.orbeon.com/form-runner/advanced/buttons-and-processes/actions-xforms#xf-dispatch

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.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].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Custom Form Builder Publish Behaviour

Alessandro  Vernet
Administrator
Hi Kris, did you get a chance to try writing your own logic in your own
custom model, as described in my previous message? If so did it work for
you?

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.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].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Custom Form Builder Publish Behaviour

kiskandar
Hi Alex,

I did manage to perform the dispatch without the dialog box. Did encounter a
small gotcha with the custom model because I initially refer to the custom
model with its own ID, but it's actually combined into fr-form-model.

I ended up passing the custom parameter as a HTTP header though since we
need the custom parameter to be available in the request sent to the
persistence API and we already have a filter to copy request parameters into
request header.

Kind regards
Kris

--
Sent from: http://discuss.orbeon.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: Custom Form Builder Publish Behaviour

Alessandro  Vernet
Administrator
Excellent Kris, I am glad you were able to publish by passing the dialog, and
thank you for the update.

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.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].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet