Untitled
unknown
plain_text
8 months ago
1.1 kB
6
Indexable
buildForm(): void {
const questionsArray = this.questionsForm.get('questions') as FormArray;
this.questions.forEach((question, index) => {
const optionsArray = this.fb.array(
question.options.map(option =>
this.fb.group({
option_id: [option.idOption],
seleccionada: [false]
})
)
);
const otroGroup = this.fb.group({
texto: ['', [
Validators.required,
Validators.minLength(3),
Validators.maxLength(250), // Adjust to 50 for question with idQuestion = 4 if needed
Validators.pattern(/^[^´'|\°><[\]{}()=&]*$/) // Excludes special characters
]]
});
questionsArray.push(
this.fb.group({
id_question: [question.idQuestion],
options: optionsArray,
otro: otroGroup,
showOtro: [false] // Track if "Otro" should be visible
})
);
// Initialize showOtro array
this.showOtro[index] = false;
});
}Editor is loading...
Leave a Comment