Sulu: Form mandatory validation triggers on disabled fields

Created on 25 Jun 2019  路  6Comments  路  Source: sulu/sulu

| Q | A
| --- | ---
| Bug? | yes
| New Feature? | no
| Sulu Version | sulu-2.0

Actual Behavior

Form validation triggers on mandatory disabled fields, which prevents form from being saved.

Expected Behavior

Form validation doesn't insist on fill disabled mandatory fields.

Steps to Reproduce

<property name="relative" type="checkbox">
</property>
<property name="url" type="url" mandatory="true" visibleCondition="relative != true" disabledCondition="relative == true">
</property>
<property name="relativeUrl" type="text_line" mandatory="true" visibleCondition="relative == true" disabledCondition="relative != true">
</property>

Possible Solutions

Either form validation should skips disabled fields, or mandatory field should be conditionable like disabledCondition (which will give more freedom to use forms).

Bug

Most helpful comment

I think the main problem here is that we evaluate all the conditions you can pass to via XML (disabledCondition, visibleCondition, ...) too early in the frontend. We probably have to postpone that jexl evaluation, in order to react on things like this properly. This is also the main reason for #5291...

I think I am going to have a look at this after I finished #5608. I don't think you can really help out here, unless you get chin-deep into the code :see_no_evil:

All 6 comments

Will this be available any time soon?

Or is there currently another way to achieve conditionable mandatory validation?

It's related to this issue in way #5312

The validation is handled in the frontend, so its not related to #5312.

I can currently not say when this is been fixed, as it would need first some concept.
Currently out of the form metadata a JSON Schema is generated which is validated in the frontend before submitting the form. At the current state the generated schema does not consider disableConditions or visibleConditions. At the end I think we need to generate then something like the conditional schemas here: https://json-schema.org/understanding-json-schema/reference/conditionals.html if visible or disable condition is set. I think the heavy part will be converting jexl (which we use in for conditions) into this json schema conditions.

A fix for this would be much appreciated, without it we are very limited if complex conditional forms are required.

Is there a way we could help with this maybe?

I think the main problem here is that we evaluate all the conditions you can pass to via XML (disabledCondition, visibleCondition, ...) too early in the frontend. We probably have to postpone that jexl evaluation, in order to react on things like this properly. This is also the main reason for #5291...

I think I am going to have a look at this after I finished #5608. I don't think you can really help out here, unless you get chin-deep into the code :see_no_evil:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mtnorthrop picture mtnorthrop  路  6Comments

kfrohwein picture kfrohwein  路  7Comments

danrot picture danrot  路  6Comments

alexander-schranz picture alexander-schranz  路  4Comments

alexander-schranz picture alexander-schranz  路  3Comments