Using dependency feature with custom presenters

Hi all

We have a custom presenters for date input and address input. We would like to make these mandatory dependent on another field being not empty. When we look at the list of dependency actions, the only option is “hide”.

Is there a way to put “make mandatory”, and “make not mandatory” into a custom presenter code?


Dependencies are not currently supported for Code Studio components (other than hide/show). Because they are bespoke, there is no way for the system to know how to implement those effectively on unfamililar HTML/JS code.

A solution might be possible in future, maybe with some event hooks in the frontend JS code allowing you to determine what happens in your code when a field needs to be made mandatory for example. Please raise an Idea for this if you think that would be of use.

Hi Bob, this one arose due to quite a straightforward use case.

We have a form with a submit button to add records to a list, then a separate ‘next’ submit button to progress to the next page. Both submits are in a widget group so that if you fill out the form and click next, it’ll still add that to the list and progress. If an empty added item is added, a rule just deletes that record.

The difficulty is that some fields need to be mandatory (but only if you’ve begun filling in the form) as although its fine to skip the page without adding any, it’s not ok to half complete the fields and add.
So in this scenario, we’d normally just have ‘make mandatory’ dependencies on the fields if any have been filled out - which only works if they’re not custom presenters.

I’ve thought about adding JS to programmatically add a ‘required’ class to the input elements, but I can’t trigger that without being able to run it on the frontend from say an ‘E1’ event. I know fragment call backs respond to those events, but the code needs to be frontend I think to add the HTML class.

I can’t think of another solution as the whole form needs to be taken into account dynamically.
Any ideas?


Ignoring custom presenters, would this work anyway with just dependencies? Presumably each required field would need dependencies to every other required field? If you have more than a couple of fields this would quickly become impractical to configure. Unless you are assuming they will always fill out the form in order, and therefore all your dependencies are based on the first fireld only.

As an alterative approach, could you just set all necessary fields as required, and have the Next/Skip button just be just a link to the next page (with an event trigger if some action is required behind the scenes), so it doesn’t try to submit the form at all? You could use the ‘Abandon prompt’ setting on the form to warn the user if they had part filled out the form.

Another option, or additionally to the above, would be to only show the form based on a user indicating they want to add the record at all. Maybe a Generic Switch element which when enabled reveals the form with all necessary fields mandatory, to make it more clear it’s all or nothing. While disabled you could instead show the Next button which is just a link as above.

1 Like

Ok, that’s really useful.
Thanks for the suggestions!