Change fields.submit value on dependent call?

Change fields.submit value on dependent call?

ITAppData@HomeStreet.comITAppData@HomeStreet.com Posts: 54Questions: 13Answers: 2
edited November 2023 in Editor

I couldn't quite find this discussed before, but is it possible to set the field submit option (here) within a dependent call?

Essentially I know I can show and hide or disable the fields dynamically, however on the server I want to make them somewhat conditionally required, by having the backend NotEmpty() validator handle the work. However, just hiding or disabling the fields, still makes them submit to the server, so when no data is included, it still causes validation errors.

I've done this in the past with some clearing and adding of fields dynamically, but was hoping it could be done a bit cleaner by simply setting the "submit" option on the fields when the dependent value is provided.

Hopefully that makes sense.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,564Questions: 1Answers: 10,479 Site admin
    Answer ✓

    It isn't possible to change the submit option for a field after initialisation at the moment. However, you could use preSubmit to modify the data being sent to the server based on whatever logic condition you have. Just delete the data for the field in question.

    Making the submit option API'able is a nice idea though - thank you for the suggestion.

    Allan

  • ITAppData@HomeStreet.comITAppData@HomeStreet.com Posts: 54Questions: 13Answers: 2

    Thanks as always @allan!

    I will play around with the preSubmit event :smile:

    Having the the submit option available through the API would be handy.

Sign In or Register to comment.