label required

This commit is contained in:
annampak 2018-01-03 17:19:52 +02:00
parent 21ba057390
commit 3d8860870a
3 changed files with 9 additions and 10 deletions

View File

@ -4,12 +4,12 @@
<div class="row">
<div class="form-group col-md-12">
<label>Label</label>
<input type="text" class="form-control" formControlName="label" id="label">
<!-- <div *ngIf="form.get('label').invalid && (form.get('label').dirty || form.get('label').touched)" class="alert alert-danger"> -->
<!-- <div *ngIf="form.get('label').errors.required" class="alert alert-danger">
Name is required.
</div> -->
<!-- </div> -->
<input type="text" class="form-control" formControlName="label">
<div *ngIf="form.get('label').invalid && (form.get('label').dirty || form.get('label').touched)">
<div *ngIf="form.get('label').errors.required" class="alert alert-danger">
Label is required.
</div>
</div>
</div>
</div>
@ -67,8 +67,7 @@
</a>
</div>
<button class="btn btn-primary" style="margin-top:20px;" type="submit">Save</button>
<!-- [disabled]="!form.valid" -->
<button class="btn btn-primary" style="margin-top:20px;" type="submit" [disabled]="!form.valid">Save</button>
</form>
</div>
<p>Form value: {{ form.value | json }}</p>

View File

@ -38,7 +38,7 @@ export class SectionFormComponent {
// (<FormArray>this.form.get("fieldGroups")).push(fieldGroup.buildForm());
// }
addField() {debugger;
addField() {
let fieldSet: FieldSet = new FieldSet();
let field: Field = new Field();
//let fieldGroup: FieldGroup = new FieldGroup();

View File

@ -36,7 +36,7 @@ export class DatasetProfileModel extends BaseModel implements Serializable<Datas
// })
formGroup.addControl('pages', this.formBuilder.array(pagesFormArray));
formGroup.addControl('label', new FormControl(this.label));
formGroup.addControl('label', new FormControl(this.label, Validators.required));
return formGroup;
}