@ -10,7 +10,7 @@ export default class extends Controller {
let selectedValue = this.element.value
let conditional_for = JSON.parse(this.element.dataset.info)
Object.entries(conditional_for).map(([targetQuestion, conditions]) => {
if(conditions.includes(selectedValue)) {
if(conditions.map(String).includes(String(selectedValue))) {
} else {
const textNumericInput = document.getElementById(`case-log-${targetQuestion.replaceAll("_","-")}-field`)
if (textNumericInput == null) {
@ -35,4 +35,12 @@ RSpec.describe "Form Conditional Questions" do
expect(page).to have_field("case-log-leftreg-field", with: "")
end
context "when a conditional question has a saved answer", js: true do
it "is displayed correctly" do
case_log.update!(postcode_known: 1, property_postcode: "NW1 6RT")
visit("/logs/#{id}/property-postcode")
expect(page).to have_field("case-log-property-postcode-field", with: "NW1 6RT")
@ -365,6 +365,26 @@
"header": "",
"description": "",
"questions": {
"postcode_known": {
"check_answer_label": "Do you know the property postcode?",
"header": "Do you know the property’s postcode?",
"hint_text": "",
"type": "radio",
"answer_options": {
"1": {
"value": "Yes"
},
"0": {
"value": "No"
}
"conditional_for": {
"property_postcode": [
1
]
"hidden_in_check_answers": true
"property_postcode": {
"check_answer_label": "Postcode",
@ -830,9 +850,9 @@
"other_postcode": {
"check_answer_label": "Postcode of previous accommodation if the household has moved from settled accommodation",
"header": "Postcode for the previous accommodation",
"hint_text": "If the household has moved from settled accommodation immediately prior to being re-housed",