I am doing dynamic form by referring this link click here and its working for all textarea, multi select and date type. But for checkbox not working while submitting the form I am getting the out put like the below
{"name":"df","food":"Pizza","description":"zx v","color":["Red"],"incidentdate":"2017-09-22","options":true,"gender":"Female","submit":null}
In this how I can identify which checkbox is selected? here just showing "options":true
I have tried in the below format but its not working.
template: `<div
class="dynamic-field form-input"
[formGroup]="group">
<label>{{ config.label }}</label>
<span *ngFor="let option of config.options">
<input type="checkbox" [formControlName]="config.name" value="{{option}}" />{{option}}
</span>
</div>`
Please let me know am I doing anything wrong?
Here is the config
this.config =
{
"label" : "Title",
"type" : "input",
"name" : "title"
},
{
"label" : "Status",
"type" : "select",
"name" : "status",
"options" : [
"Accepted",
"Rejected",
"Pending",
"Complete"
],
"placeholder" : "Select an option"
},
{
"label" : "What options?",
"type" : "checkbox",
"name" : "question",
"options" : [
"Option D",
"Option E",
"Option F"
]
},
{
"label" : "Incident Date",
"type" : "date",
"name" : "incidentdate"
},
{
"label" : "Comments",
"type" : "textarea",
"name" : "comments"
},
{
"label" : "Description",
"type" : "textarea",
"name" : "descriptions"
},
{
"label" : "Is it good?",
"type" : "radio",
"name" : "gender",
"options" : [
"Male",
"Female"
]
},
{
"label" : "Who is responsible?",
"type" : "multiselect",
"name" : "responsible",
"options" : [
"Manager",
"Supervisor",
"Site-Supervisor"
]
},
{
"label" : "Submit",
"type" : "button",
"name" : "submit"
}
Thank you