I have a D8 form where when a test involving the value of other fields fails, if the publish (field = status) checkbox has been checked the validation should fail and the checkbox should be cleared when the form with error message is re-displayed.

I have made numerous attempts in permutations of custom callback for #validate, #element_validate and #value_callback, as set dynamically by hook_form_alter, using set(), setValue(), setValueForElement(), etc.

while the function fires in each case, and the setErrorByName() call works in each, in no case is the Publish checkbox cleared when the form reloads.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.