Compare values in two search widget fields

Say you are building a page with a date range search function to display records. There is no way, even in code, to ensure that the date in the ‘to’ field is greater than the date in the ‘from’ field (they are both the same field, so have the same UID).

It would be good if fields could have a relationship to another field on the same widget, say must be >, <, =, >=, <=

Hi Simon,

Thank you for pointing this out.

In the context of an edit form, the current behaviour makes sense, but in the context of a search form you can legitimately submit two values for the same field.

The Code Studio “Fragment Validators” is the right place to implement this kind of inter-field validation but, as you point out, fragment_presenter.get_values() provides the data keyed by the field_path, obscuring one of the two values and making your desired validation impossible.

We will add a solution to this problem to our todo list for the platform.

In the meantime, you can work around this by making one of your two input fields a composite. For example, use the “Field’s Date” function (with the “Input date” presenter). In this way you can expose the two values to your Fragment Validator.

Let me know if you need further help.


Thanks, that’s a useful workaround.