This works fine in that it does not give validation errors for inputs that are on other steps. However when the validation is successful and I move to the next step, all the inputs have a green "success" background on them.
Obviously this is not correct at this point. How can I fix this?
I don’t think this is a bug. It’s because AJAX validation return in JSON only invalid fields. In that case ActiveForm’s javascript callback function assume that all fields which are not listed in response are valid.
I have another idea. You can wrap each step with different form (each with same action). Then validation should change only current form. I know it’s quite “ugly” but sometimes we have to make sacrifices . Maybe removing green background in afterValidate function would be better solution for you.
ActiveForm’s JS code keeps a state of each field. On page load all fields are marked as not checked and even when validating whole form they should not be marked either as valid or not. Only after being modified by user (or getting focused) validation assigns css classes to them.
Check if you don’t call change() or focus() event on fields that haven’t been yet filled by the user. Maybe you clear the whole set of fields when advancing to the next step?