orbeon / orbeon-forms

Orbeon Forms is an open source web forms solution. It includes an XForms engine, the Form Builder web-based form editor, and the Form Runner runtime.
http://www.orbeon.com/
GNU Lesser General Public License v2.1
515 stars 221 forks source link

Function to access the value of a control #2910

Closed ebruchez closed 6 years ago

ebruchez commented 8 years ago

Issue #2471 is about accessing the value of a control within a section template. This issue is about a function independent from section templates.

We could name the function, as suggested in #2471, fr:control-value($name).

See also #2471, #2909, #309, #2113.

ebruchez commented 8 years ago

Must work from

The function would work locally within a section template (later see #2471).

Dependencies

Formulas raise the question of dependencies, which we currently (optionally, and enabled by default since 2018.1 for new forms) handle via variables.

In addition, also handle PathMap dependencies, where fr:control-value('foo') resolves to a bind by name, which translates to a path.

Repeat resolution

Currently, we have resolution with:

We need to determine how fr:control-value() resolves repeated controls.

ebruchez commented 8 years ago

One way to go about this:

This allows DependencyAnalyzer to remain unchanged when handling calculate and default formulas.

ebruchez commented 6 years ago

For repeat resolution, the first use case we have are dynamic LHHA. In this case, the expression is in the view. It should probably resolve the same way we resolve controls within actions, "the control which is the closest by following repeat iterations and repeat indexes is chosen". This is implemented by FormRunner.resolveTargetRelativeToActionSource. Note that there are two options:

Since this is resolved from LHHA which are on controls which are relevant and necessarily have binds, could we use the regular bind resolution instead? Not obvious as this could also be used from other places.

Also, what type should the value have? If the node has a type, say xs:date, should we return that? Or the formatted value? I would think that the value should have the type when possible, and that formatting should be done somewhere else, like with xxf:r().

Thinking we might want to have:

Should the user be allowed to choose:

Tasks:

ebruchez commented 6 years ago

For PathMap, in theory, we could build the projection if we know statically the ancestors of the control. For example:

fr:control-string-value('foo')

Points to the projection:

instance('fr-form-instance')/section-1/section-2/grid-3/foo

Except that the same cached expression could occur in two different forms with a different data model. So that won't work without making sure the expression is different!

So I suggest that for now, we do not include support for PathMap.

ebruchez commented 6 years ago

Documented