Change fields.submit value on dependent call?
Change fields.submit value on dependent call?
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
It isn't possible to change the
submit
option for a field after initialisation at the moment. However, you could usepreSubmit
to modify the data being sent to the server based on whatever logic condition you have. Justdelete
the data for the field in question.Making the
submit
option API'able is a nice idea though - thank you for the suggestion.Allan
Thanks as always @allan!
I will play around with the preSubmit event
Having the the submit option available through the API would be handy.