Add explicit conditional checks to restore status of input fields. If selected or checked attribute is rendered, then that option will be selected or checked even if the value of the selected or checked attribute is empty. The browser will select the last element that has a selected or checked attribute regardles of whether or not that attribute is empty.