You can use the save-draft button to allow saving without validating. See this documentation. But save-draft will entirely skip checking validation before saving.
Update
If you want to validate (with "Required" or constraint formulas) depending on the button pressed, I can think of the following way.
Whether a field is required can be expressed by an XPath expression. Somehow that XPath expression would have to depend on the current button pressed, and validation would have to be reapplied at that time. So you could do the following:
- Add a hidden form field, say
validation-mode, which will contain a value identifying whether the user has pressed one button or the other, say save or send or blank.
- Make your validations depend on that field (using
$validation-mode).
- Write a new process associated with each of the "Save" or "Send" buttons which:
- Sets the value of the hidden field, say to
save or send.
- Forces recalculation/revalidation. There is no built-in action for this yet, but you can do so with the
xf:dispatch(name = "xforms-recalculate", targetid = "fr-form-model").
- Then continues with the process as usual.
So the processes would look like:
<property as="xs:string" name="oxf.fr.detail.process.save.*.*">
xf:setvalue(
ref = "bind('validation-mode-bind')",
value = "'save'"
)
then xf:dispatch(
name = "xforms-recalculate",
targetid = "fr-form-model"
)
then validate-all
then expand-all
then save-final
</property>
<property as="xs:string" name="oxf.fr.detail.process.send.*.*">
xf:setvalue(
ref = "bind('validation-mode-bind')",
value = "'send'"
)
then xf:dispatch(
name = "xforms-recalculate",
targetid = "fr-form-model"
)
then validate-all
then expand-all
then send(
uri = "http://posttestserver.com/post.php",
method = "post",
content = "xml",
replace = "all"
)
</property>