Why conditional logic doesn't work properly in my form?