You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							35 lines
						
					
					
						
							1.2 KiB
						
					
					
				
			
		
		
	
	
							35 lines
						
					
					
						
							1.2 KiB
						
					
					
				| <%= f.govuk_radio_buttons_fieldset question_key, | |
|     legend: { text: question["header"], size: "l" }, | |
|     hint: { text: question["hint_text"] }, | |
|     small: (question["answer_options"].size > 5) do %> | |
|  | |
|     <% question["answer_options"].map do |key, val| %> | |
|       <% if key.starts_with?("divider") %> | |
|         <%= f.govuk_radio_divider %> | |
|       <% else %> | |
|         <%= f.govuk_radio_button question_key, key, label: { text: val }, onchange: "displayConditional()" %> | |
|       <% end %> | |
|     <% end %> | |
| <% end %> | |
|  | |
| <script> | |
|   function displayConditional() { | |
|     const show_if = <%= raw question["show_if"].to_json %>; | |
|     if(show_if !== null){ | |
|       const conditionalQuestionKey = <%= raw question_key.to_json %>; | |
|       const conditionalQuestion = document.getElementById(conditionalQuestionKey + "_div") | |
|       conditionalQuestion.style.display = "none"; | |
|       Object.entries(show_if).forEach(([key, values]) => { | |
|         values.forEach((value) => { | |
|           let answerOption = document.getElementById(key.replace("_", "-") + "-" + value + "-field") | |
|           if(answerOption !== null) { | |
|             if(answerOption.checked){ | |
|               conditionalQuestion.style.display = "block" | |
|             } | |
|           } | |
|         }) | |
|       }); | |
|     } | |
|   } | |
|   displayConditional() | |
| </script>
 | |
| 
 |